Java Reference
In-Depth Information
All these tasks can be turned on and off with configuration. The first two tasks will
raise a ServletException in case of a failure. The extension point here is provided by the
abstract handleRequestInternal method. All subclasses must implement this template
method to provide custom implementation. Thus, AbstractController is a convenience
base class to simplify page controller implementations.
I will put AbstractController into use with a very simple use case. The eInsure appli-
cation needed to display support and help information to allow the users to comfortably
handle the different functions of the application. Listing 3-18 shows the controller for
one such scenario.
Listing 3-18. PolicyQuoteHelpController.java
public class PolicyQuoteHelpController extends AbstractController {
protected ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return new ModelAndView("policyquotehelp");
}
}
The PolicyQuoteHelpController does not invoke any business logic. Instead, it acts as
a read-only controller, just transferring control to the next view. But before doing so, it
checks whether the request is by the HTTP GET method and a session already exists. Note
that these two options are set through configuration, as shown in Listing 3-19.
Listing 3-19. spring-config.xml
<beans>
<bean name="/policyquotehelp.do" class="com.apress.insuranceapp. å
web.controller.PolicyQuoteHelpController">
<property name="supportedMethods" value="GET"/>
<property name="requireSession" value="true"/>
</bean>
</beans>
Search WWH ::




Custom Search