In the previous chapter you learned how to use Spring's Web MVC Framework. We explored how to implement controllers, how to create models, and how to map incoming requests to relevant controllers. This chapter will show you how to render views based on the models your controllers return.
We reviewed the requirements for a well-designed MVC package. One of the most important is that the controller infrastructure should be view-agnostic. You've seen how Spring achieves this by using logical view names in combination with components called view resolvers.
This chapter explores the view resolvers that Spring provides. Each one of them offers a unique way to transform logical view names to resources capable of rendering the view itself (such as a JSP or Velocity template). It's also possible to implement custom view resolves for additional view technologies.
First, we will introduce some of the basic concepts through an example. Then we will explain some of the view technologies Spring integrates with, such as JavaServer Pages, Velocity, and iText PDF. We'll also cover the features included to simplify the creation of HTML forms. You can use this functionality when writing JSPs and FreeMarker and Velocity templates.
After working through this chapter, you will know how to use the view technologies integrated with Spring to create a flexible, maintainable user interface for your web applications, not only using HTML-based views, but also variations such as those that can produce reports in Excel or PDF format.
The next chapter will discuss how to integrate Spring with other web frameworks such as Struts and Tapestry. Together with the previous and the next chapter, this one completes the trio of chapters detailing Spring's support for building clean but powerful web tiers based on your needs and preferences, with the technologies of your choice.