The controller

The Spring controller handles the requests to carry out business logic; these controllers can also be referred to as handlers, and their methods as handler methods. The Spring framework provides AbstarctUrlViewController, ParameterizableViewController, ServletForwardingController, and ServletWrappingController as controllers. One of these controllers needs to be subclassed to customize the controller in the Spring 2.5-based web application. However, Spring now supports annotation-driven controllers using the @Controller annotation. The following configuration enables the annotation-based controllers:

<mvc:annotation-driven /> 

The annotation-based controllers need to be discovered to execute the handler method. The following configuration provides information to the framework about which packages to scan to discover the controllers:

<context:component-scan base-package="com.packt.*"> 
</context:component-scan> 

The @RequestMapping annotation is used to annotate either a class or a method for the declaration of a specific URL, which it can handle. Sometimes, more than one method can be annotated for the same value of the URL, which supports different HTTP methods. The method=RequestMethod.GET attribute of the @RequestMapping annotation is used to specify which HTTP method will be handled by the method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.189.23