Chapter 3. Integrating Other Clients

I'd like to say that I love everything about kayaking, but that's not quite true. I hate dragging my boat to the put-in, and back out again. In fact, if I have to hike more than a couple of miles to get where I'm going, I'm probably not going to run the river. It's not that I hate hiking, or even backpacking. It's just that those in my sport don't hike with our boats enough, so we haven't usually thought through the problem.

Note

New Spring code gets introduced in the sandbox. When the code matures, it's added to the main Spring project.

Building a Struts User Interface

In the first example, you'll build a portion of our user interface with Java's most popular user interface framework, Struts. You'll also learn how to wire it to Spring.

If you're starting a new project, you may decide to choose an alternative to Struts. We believe that emerging MVC frameworks improve the user and developer experience, but Struts is still the most popular choice.

How do I do that?

The Struts user interface looks much like the web MVC interface. You'll configure a central dispatcher. The dispatcher will send requests to a controller, and the controller will invoke business logic in the form of actions.

First, you need to configure Struts. That happens in two places: web.xml configures your central dispatcher and struts-config.xml manages the Struts Controller. Example 3-1 shows web.xml.

Example 3-1. web.xml

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application ...

Get Spring: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.