Summary


In this chapter you've seen most of the features of the Spring Web MVC framework.

We've reviewed the architecture of Spring Web MVC, including its DispatcherServlet and the concept of a ModelAndView, and strongly typed controllers such as the AbstractController and the SimpleFormController. Together, with features such as HandlerMappings, HandlerInterceptors, and ExceptionResolvers, you can control the flow of your web application and respond to errors.

LocaleResolvers and MultipartResolvers complete the picture.

One of the major advantages of Spring's MVC framework is that it clearly separates all responsibilities in a web application. Models contain data to be rendered to the response; views perform the actual rendering; while controllers process user interaction, invoke the middle tier to obtain the model data to display, and choose the appropriate view to generate the response for the user. If you're familiar with Struts, you should be able to map these concepts onto those used in Struts: Models correspond to JavaBeans, exposed by JSPs in a Struts action; Spring views correspond to JSPs used in a Struts application; and a Spring controller corresponds to a Struts Action. But you should note that Spring provides an elegant decoupling of these three concepts, and expresses the concepts in a way that is more independent of JSP or the Servlet API, maximizing potential for reuse.

We've seen that Spring Web MVC is completely view agnostic. Spring's model and view abstraction is independent of the Servlet API, and is equally suited to generating HTML, XML, other text, or binary content.

Spring Web MVC is an extremely flexible solution to building web applications. Although we've covered the most important topics in this chapter, you can easily extend Spring Web MVC to fully match your requirements in more complex projects.

While you may be feeling a bit overwhelmed with all the information in this chapter, remember that you don't need to use all the advanced features that Spring MVC provides unless you are writing a sophisticated application — in which case you will be grateful for using a web application framework that can cope with complex, unusual scenarios.

In the next chapter, we'll cover some of the view technologies integrated with Spring. One of the unique features of Spring's web infrastructure lies in the fact that it's completely agnostic to views. You can use Velocity, JavaServer Pages (JSPs), and Velocity as well as Freemarker templates and even convenience classes to generate PDF and Excel documents.



Professional Java Development with the Spring Framework
Professional Java Development with the Spring Framework
ISBN: 0764574833
EAN: 2147483647
Year: 2003
Pages: 188

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net