With the widespread use of SPRINGMVC, many of its useful and effective functions should be more well-known, the following describes the SPRINGMVC three kinds of processors:
One, Beanname processor (default)
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd "><!--Beamname Processor mapping the first default, you can not write---<bean id= "beannameurlhandlermapping"class= "Org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" > <!--sort use, if there is a conflict with which controller will prevail, the smaller the value, the higher the--& Gt <property name= "order" value= "0" ></property> </bean> <!--Controller--<bean name= "/home.ac tion "class= "Cn.cfs.springmvc.controller.HomeController" > </bean> <!--internal Resource View resolver prefix + logicname + suffix- <bean name= "Internalresourceviewresolver"class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name= "prefix" value= "/ web-inf/jsps/"></property> <property name=" suffix "value=". jsp "></property> </BEAN>&L T;/beans>
Note: This processor is the default processor for SPRINGMVC, which controls which action class (Class of control layer, controller Class) corresponds to the access request path through the bean's Name property. It is worth noting that the 3.0 was not used in the name of the write/backslash, the 3.0 version after the need to add
Second, simple processor (for multiple request path binding the same controller)
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd "><!--Simple processor mapping the second, simple configuration, different path requests correspond to the same action case--<bean id= "simpleurlhandlermapping"class= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" > <property name= "Mappings" > <props> <prop key= "/a.action" >test</prop> <prop key= "/b.action" >test </prop> <prop key= "/c.action" >test</prop> </props> </property& Gt <!--sort use if there is a conflict with which controller is <property name= "order" value= "0" ></property> </bean> &L t;! --Controller--<bean id= "test" name= "/home.action"class= "Cn.cfs.springmvc.controller.HomeController" > </bean> <!--internal Resource View resolver prefix + logicname + suffix- <bean name= "Internalresourceviewresolver"class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name= "prefix" value= "/ web-inf/jsps/"></property> <property name=" suffix "value=". jsp "></property> </BEAN>&L T;/beans>
Note: This processor is determined by the key in prop to determine the specific request jump path, the following value corresponding to the Controller ID
Third, ClassName (class name) processor
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd "><!--ClassName Processor mapping the third type according to the Controller's class name to automatically map, access when the class name first letter needs lowercase, if the class naming specification, for example: HomeController can omit the controller, directly knocked Home.action can access-- > <bean id= "controllerclassnamehandlermapping"class= "Org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" > <!--sort use, if there is a conflict with which controller will prevail --<property Name= "Order" value= "2" ></property> </bean> <!--Controller--<b Eanclass= "Cn.cfs.springmvc.controller.HomeController" > </bean> <!--internal Resource View resolver prefix + logicname + suffix- <bean name= "Internalresourceviewresolver"class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name= "prefix" value= "/ web-inf/jsps/"></property> <property name=" suffix "value=". jsp "></property> </BEAN>&L T;/beans>
Note: This processor is defined by the name of the controller class you define to do the mapping, you must pay attention to access the class name when the first letter to lowercase, if the class name is very canonical, such as HomeController then the controller can be omitted, Directly with home.action to access, notice me here Web. XML is configured in the Dispatcherservlet mapping intercept is a request with the suffix. Action so access is home.action if configured Yes/ The slash does not need to take the. Action
SPRINGMVC Basics-Mastering three types of processors