Spring MVC Tutorial

Source: Internet
Author: User
Tags spring mvc tutorial

Spring MVC is a model-view-controller (MVC) Web framework built on the central front-end controller servlet (Dispatcherservlet), which is responsible for sending each request to the appropriate handler, using the view to ultimately return the concept of the response result. Spring MVC is part of the spring product portfolio, which has the spring IOC container tightly coupled with spring loose coupling, so it has all the benefits of spring.

Springmvc as shown in the architecture diagram


Spring WEB MVC Framework Features

Clear role Partitioning: Controller, Validator (validator), Command object, Form objects (Form object), model object (models), The servlet Dispatcher (Dispatcherservlet), the processor mapping (handler mapping), the view resolver, and so on. Each role can be implemented by a dedicated object.

Powerful and straightforward configuration: both the Framework class and the application class can be configured as JavaBean, supporting references across multiple context, such as references to business objects and validators (validator) in the Web controller.

Adaptable, non-intrusive: Depending on the application scenario, you can select the appropriate controller subclass (simple, command, form, Wizard, Multi-Action, or custom), rather than from a single control (such as the action/- Actionform) inheritance.

Reusable business code: You can use an existing business object as a command or Form object without having to extend the base class of a particular framework.

Customizable bindings (binding) and Validation (validation): For example, type mismatch as an application-level validation error, which can hold the wrong value. such as localized date and number bindings and so on.

Customizable handler mapping and view resolution:spring provide the simplest URL mapping to complex, dedicated customization strategies.

Flexible model conversions: In the Springweb framework, map-based key/value pairs are used to easily integrate with various view technologies.

Customizable localization and theme (theme) parsing: supports the optional use of the Spring tag library in JSPs, support for jstl, support for velocity (no additional middle tier), and more.

Simple and powerful JSP tag library: Support includes many features such as data binding and themes (theme). It provides maximum flexibility in terms of marking.

JSP Form Tag library: The form tag Library introduced in Spring2.0 makes it easier to write forms in JSP.

The life cycle of the Spring bean can be limited to the current HTTP request or HTTP Session. To be precise, this is not the Spring MVC framework itself but belongs to the Webapplicationcontext container used by sping MVC.

The approximate execution process for Spring MVC is as follows:

1, the first browser to send a request to the front-end controller Dispatcherservlet,dispatcherserlvet according to the request information, based on a certain principle to choose the appropriate controller to process and delegate the request to it.

2、页面控制器接收到请求之后进行功能处理,首先需要收集、绑定请求参数到一个对象(命令对象),并进行验证,然后将该对象委托给业务对象进行处理(service层);业务对象处理之后控制器将返回一个ModelAndView(模型数据和逻辑视图名);

3, Dispatcherservlet according to the return of the logical view name, select the appropriate view for rendering (interface display, resource loading), and the model data passed in so that the view rendering.

4. The front controller returns a response to the client browser.

Spring MVC Tutorial

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.