There are three ways to handle requests to the corresponding controller in SPRINGMVC:
First, beannameurlhandlermapping (default)
The processor corresponds to the request based on the Bean's Name property
<bean class= "org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> dispensable
For example:
<bean name= "/index3" class= "Com.controller.Controller1" > </bean>
Then the http://localhost:8080/spring/index3 will correspond to the Controller1, note that the name "/" must have.
Second, simpleurlhandlermapping
The processor is a simple mapping process
For example:
<bean class= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
<property name= "Mappings" >
<props>
<prop key= "/index2" >index1</prop>//index2 represents the request path, INDEX1 represents the ID of the corresponding controller
</props>
</property>
</bean>
<bean id= "index1" class= "Com.controller.Controller1" ></bean>
then the http://localhost:8080/spring/index2 will correspond to the Controller1.
If our request is simply to jump to a page then you can go through:
1. <bean name= "/index" class= "Org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
When we use Http://localhost:8080/spring/index, we can jump directly to index.jsp, that is, the controller directly corresponds to the request path to a page with the same name. Here we use the default mapping processor, you can also use simpleurlhandlermapping, then the page will jump to the same name as the key page
2. <bean id= "index1" class= "Org.springframework.web.servlet.mvc.ParameterizableViewController" >
<property name= "ViewName" value= "index" ></property>
</bean>
The Simpleurlhandlermapping method is used here .
SPRINGMVC Mapping processor in the