1 Other non-annotated processor mappers and adapters1. 1BeanNameUrlHandlerMapping (mapper) matches the name of the spring container bean according to the request URL (xxxx.action) to find the corresponding bean (program-written handler)1. 2SimpleUrlHandlerMapping (Mapper)<!--simple URL mapping, centrally configured bean ID corresponding to the URL--<beanclass="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="Mappings"> <props> <prop key="/itemstest1.action">itemController1</prop> <prop key="/itemstest2.action">itemController2</prop> </props> </property> </bean>Note: Multiple processor mappers are configured in Springmvc.xml, and multiple processor mappers can coexist. Which mapping succeeds is used. 1the. 3SimpleControllerHandlerAdapter (adapter) requires that the handler (Controller) written by the program need to implement the Controller interface. <!--Configuring the processor adapter, the SPRINGMVC framework determines whether the class is a processor adapter and <, based on the Handleradapter interfaceBeanclass="Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>1. 4HttpRequestHandlerAdapter (adapter) in Springmvc.xml configuration: Httprequesthandleradapter<!--httprequesthandleradapter Adaptor--<beanclass="Org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"/>requires handler to implement Httprequesthandler interface1.4. 1 Development Handler Public classItemController2 implements Httprequesthandler {@Override Public voidHandleRequest (httpservletrequest request, httpservletresponse response) throws Servletexception, Ioexcepti on {//use static data to display a list of commodity information on a JSP page//Product ListList<items> itemslist =NewArraylist<items>(); Items Items_1=NewItems (); Items_1.setname ("Lenovo Notebook"); Items_1.setprice (6000F); Items_1.setcreatetime (NewDate ()); Items_1.setdetail ("ThinkPad T430 Lenovo notebook computer! "); Items items_2=NewItems (); Items_2.setname ("Apple Phone"); Items_2.setprice (5000F); Items_2.setdetail ("iphone6 Apple Phone! "); Itemslist.add (Items_1); Itemslist.add (items_2); Request.setattribute ("itemslist", itemslist); //forward to JSP pageRequest.getrequestdispatcher ("/web-inf/jsp/itemslist.jsp"). Forward (request, response); }}1.4. 2 Configuration Handler<!--handler2--<bean id="ItemController2" class="Cn.itcast.springmvc.first.ItemController2"></bean>using the Simple URL mapper:<!--simple URL mapping, centrally configured bean ID corresponding to the URL--<beanclass="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="Mappings"> <props> <prop key="/itemstest1.action">itemController1</prop> <prop key="/itemstest2.action">itemController2</prop> </props> </property> </bean>Mapper is based on the URL to find handler, when there are more than one mapper the same URL, all the mapper in a list queue, the map URL when the time taken from the collection, get the use, the back is no matter.
SPRINGMVC03 non-annotated and annotated processor mapper and adapters