SPRINGMVC Front-Segment Controller Processor Mapper Processor Adapter View View Resolver configuration

Source: Internet
Author: User

1. Front-section Controller

New project configuring the front-segment controller in Web. xml

<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
Classpath:spring-servlet.xml
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!--

Contextconfiglocation Configuring SPRINGMVC Load profiles (configuring processor mapper, adapters, etc.)

Note: If the processor mapper is not configured in Spring-servlet.xml, the processor adapter is loaded by default

Org.springframework.web.servlet.DispatcherServlet.properties as shown

If you do not configure Contextconfiglocation, the/web-inf/servlet name-servlet.xml (springmvc-servlet.xml) is loaded by default.

-

2. Non-annotated processor mapper

Where the processor mapper includes the default configuration non-annotated form includes the following two

Org.springframework.web.servlet.handler. beannameurlhandlermapping
Org.springframework.web.servlet.handler. simpleurlhandlermapping

3, non-annotated processor adapter

Where the non-callout processor adapter includes

Org.springframework.web.servlet.mvc. Simplecontrollerhandleradapter

Org.springframework.web.servlet.mvc. Httprequesthandleradapter////By modifying response corresponding JSON format data

4. View Parser

<bean id= "Viewresolver"
class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "prefix" value= "/web-inf/jsp/"/>
<property name= "suffix" value= ". jsp"/>
</bean>

5. Annotation form-processor Mapper and processor adapter

The default annotation processor mapper is

Org.springframework.web.servlet.mvc.annotation. defaultannotationhandlermapping

The default loading of the old version for 2.5 is recommended with 3.2 configuration with

Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

The default processor adapter is

Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter

The default loading of the old version for 2.5 is recommended with 3.2 configuration with

Recommended for

Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter

The Spring-servlet.xml is configured to

<!--processor Mapper--

<bean class= "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>

<!--Processor Adapter--
<bean class= "Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>

Note that these two sentences can be replaced by the sentence below.

<!--note-driven
<mvc:annotation-driven></mvc:annotation-driven>

Note *.do in the Controller scan package

<context:component-scan base-package= "Com.test.controller" ></context:component-scan>

SPRINGMVC Front-Segment Controller Processor Mapper Processor Adapter View View Resolver configuration

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.