Chapter III-spring MVC Introduction

Source: Internet
Author: User

First, the benefits of using spring MVC

From the MVC servlet Controller (ii), we know that to implement MVC, we're going to write a dispatcher servlet and controller class, where the dispatcher servlet will do the following work.

1. Invoke the corresponding action based on the URI.

2. Instantiate the correct controller.

3. Construct the form bean according to the request parameters.

4. Invoke the appropriate method for the Controller object.

5. Turn to a view.

In Spring MVC there is the Dispatcher Servlet, which invokes the controller's method and forwards the view. In addition to this, it has many other advantages.

Second, Spring MVC's dispatcher Servlet

Dispatcher Servlet will automatically find the configuration file under the Web-inf directory at initialization, the following naming rules for this configuration file

Servletname-servlet.xml

We can also place the configuration file somewhere else and use the Init-param element to specify the directory.

Third, controller interface

Prior to the spring mvc2.5 version, the only way to develop a controller was to implement a controller interface for spring MVC. The methods in the interface are as follows

Modelandview HandleRequest (httpservletrequest request, httpservletresponse response)

Classes that implement this interface can access the Request/response. Also be sure to return a Modelandview object that includes the picture path or view path and model name.

The implementation class of the Controller interface can handle only one action, while the annotation-based controller implements multiple request-processing actions without implement any interfaces.

Chapter III-spring MVC Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.