Spring MVC Framework
The Spring framework provides a full-featured MVC module for building WEB applications. Using spring's pluggable MVC architecture, you can choose to use a web framework such as the built-in Spring web framework or Struts. Through the policy interface, the Spring framework is highly configurable and contains a variety of view technologies, such as JavaServer Pages (JSP) technology, Velocity, Tiles, IText, and POI. The Spring MVC Framework does not know the views used, so you will not be forced to use only JSP technology. Spring MVC separates the roles of controllers, model objects, dispatchers, and handler objects, which makes them easier to customize.
The Spring Web MVC Framework is designed around Dispatcherservlet, which assigns requests to handlers with configurable handler mappings, view resolution, local language, topic resolution, and upload file support. The default handler is a very simple Controller interface, with only one method Modelandview HandleRequest (request, response). Spring provides a controller hierarchy that can derive subclasses. If your application needs to process user input forms, you can inherit Abstractformcontroller. If you need to process multiple-page input to a form, you can inherit Abstractwizardformcontroller.
The sample application helps to visually learn these features. The bank application allows users to retrieve their account information. In building a banking application, you can learn how to configure the Spring MVC framework and the view layer of the implementation framework, which includes JSTL tags (data for displaying output) and JavaServer Pages technology.
Configuring Spring MVC
To start building the sample application, configure the Dispatcherservlet for Spring MVC. Please register all configurations in the Web.xml file. Listing 1 shows how to configure the Samplebankingservlet.
Listing 1. Configuring the Spring MVC Dispatcherservlet
<servlet>
<servlet-name>sampleBankingServlet</servlet-name>
<servlet-class>
org.springframework.we.servlet.DispatcherServlet
<servlet-class>
<load-on-startup>1<load-on-startup>
<servlet>
Dispatcherservlet is loaded from an XML file into the Spring application context, and the name of the XML file is followed by the name of the servlet plus-servlet. In this example, Dispatcherservlet loads the application context from the Samplebankingservlet-servlet.xml file.
Configure the URL of an application
The next step is to configure the URL that you want Samplebankingservlet to process. Again, register all of this information in the Web.xml.
Listing 2. Configure the URL you want to process
<servlet-mapping>
<servlet-name> sampleBankingServlet<servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>