Chapter 13Replacing Your Servlets with Controllers

  • What is @RequestMapping?
  • How to utilize Spring Framework’s model and view pattern
  • Easing your life with form objects
  • Keeping the Customer Support application up-to-date

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at http://www.wrox.com/go/projavaforwebapps on the Download Code tab. The code for this chapter is divided into the following major examples:

  • Model-View-Controller Project
  • Spring-Forms Project
  • Customer-Support-v10 Project

NEW MAVEN DEPENDENCY FOR THIS CHAPTER

In addition to the Maven dependencies introduced in previous chapters, you also need the following Maven dependency:

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>4.0.2.RELEASE</version>
            <scope>compile</scope>
        </dependency>

UNDERSTANDING @REQUESTMAPPING

In Chapter 12, you were introduced to Spring Framework controllers and how to use the @RequestMapping annotation to map requests to methods within your controllers. @RequestMapping is an extraordinarily powerful tool in the Spring toolset, enabling you to map a request with the URL, the Content-Type or Accept header of the request, the HTTP request method, the presence or value of specified request parameters or headers, or any combination of these.

With @RequestMapping, you no longer need complex switches or logic branches within Servlet doGet or similar methods to select the proper ...

Get Professional Java for Web Applications 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.