Implementing View in the MVC pattern

View is the most important component of the MVC pattern. The controller returns the model to the front controller along with the logical view name. The front controller resolves to the actual view by using the configured view resolver. Spring MVC provides several view resolvers to support multiple view technologies, such as JSP, Velocity, FreeMarker, JSF, Tiles, Thymeleaf, and so on. You have to configure the view resolver according to the view technology that you use in your web application. Take a look at the following figure to understand more about the view pattern in Spring MVC:

As you can see in the diagram, Spring MVC's Front Controller has several view resolvers according to the different view technologies. But in this chapter, we will use only JSP as the view technology, and so, we will explore only the JSP-related view resolver, InternalResourveViewResolver.

A View renders the web output. There are many built-in views available for JSPs, XSLT, templating approaches (Velocity, FreeMarker), and others. Spring MVC also has view support classes for creating PDFs, Excel spreadsheets, and so on.

Controllers, typically, return a logical view name in String MVC, but Spring's ViewResolvers select a View based on the view name. Let's see how to configure the ViewResolver in a Spring MVC application.

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

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