Implementing the MVC Pattern in a Web Application using Spring

In the last couple of chapters in the book, we have seen that all examples were based on a standalone application using the Spring Framework. We have seen how Spring works to provide important features, such as the dependency injection pattern, bean life cycle management, AOP, cache management, and Spring, in the backend using the JDBC and ORM modules. In this chapter, we will see how Spring works in the web environment to address some common problems of any web application, such as workflow, validations, and state management.

Like other modules in the Spring Framework, Spring has introduced its own web framework, known as Spring Web MVC. It is based on the Model-View-Controller (MVC) pattern. Spring Web MVC supports the presentation tier, and helps you to build a flexible and loosely coupled web-based application. The Spring MVC module addresses the problem of testing the web components in the enterprise application. It allows you to write the test case without using request and response objects in the application. Here, we will discuss more about it.

In this chapter, we will not only discuss the internals of Spring MVC, but also about the different layers of a web application. We will see here the implementation of the MVC pattern including what it is, and why we should use it. We will explore the following topics in this chapter about Spring's MVC web framework:

  • Implementing MVC patterns on a web application
  • Implementing controllers patterns
  • Configuring DispatcherServlet as the Front Controller pattern
  • Enabling Spring MVC and proxying
  • Accepting request parameters
  • Processing the forms of a web page
  • Implementing a view in the MVC pattern
  • Creating JSP views in a web application
  • The View Helper pattern
  • The Composite View pattern with Apache Tiled ViewResolver

Let's look at all the aforementioned topics in detail.

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

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