O'Reilly logo

Professional Java for Web Applications by Nicholas S. Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required