I. Duties and Responsibilities
(1) handlermapping Mapper
Based on the URL requested by the client, locate the processor that processed the request, and associate the requested path with the controller.
(2) Handleradapter Adapter
The method in the controller found by the mapper is called, which includes controllers that implement the control interface, Httprequesthandler, and controller annotation adaptation, etc.
(3) Handlercontroller Controller
Executing the core business logic
II. Overview of some functions
(1) Mapper Org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping: routed to the specified controller through the Name property path of the configured action.
<Beanname= "/beanurl.action"class= "Com.jyk.springmvc.BeanNameUrlHanderMapping.HelloHAE"></Bean><Beanname= "/delete.action"class= "Com.jyk.springmvc.BeanNameUrlHanderMapping.HelloHAE"></Bean><Beanname= "/update.action"class= "Com.jyk.springmvc.BeanNameUrlHanderMapping.HelloHAE"></Bean><Beanname= "/find.action"class= "Com.jyk.springmvc.BeanNameUrlHanderMapping.HelloHAE"></Bean>
(2) Mapper The request path, such as Org.springframework.web.servlet.handler.simpleurlhandlermapping:xx.action,yy.action,oo.action, is handled by the controller labeled ID, where multiple paths are mapped to An action
<!--Mapper, this section is configured to replace the above complex configuration 1, first register the business implementation Class 2, and then configure the mapper (simple) - <BeanID= "Useraction"class= "Com.jyk.springmvc.BeanNameUrlHanderMapping.HelloHAE"> </Bean> <Beanclass= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> < Propertyname= "Mappings"> <Props> <propKey= "/beanurl.action">Useraction</prop> <propKey= "/delete.action">Useraction</prop> <propKey= "/update.action">Useraction</prop> <propKey= "/find.action">Useraction</prop> </Props> </ Property> </Bean>
(2) Adapter Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter: So spring defines an adaptation interface so that each controller has a corresponding adapter implementation class,
Have the adapter perform the appropriate method instead of the controller. In this way, when the controller is extended, only one additional adapter class is required to complete the SPRINGMVC extension, and the detailed design details of the SPRINGMVC adapter can be found in https://www.cnblogs.com/tongkey/p/7919401. HTML or 53835185, thanks to the author.
(3) Controller Org.springframework.web.servlet.mvc.ParameterizableViewController If the request is a a.jsp request path, you want to jump to the b.jsp page without a defined controller processing
<!-- JSP to JSP page forwarding controller --> < bean Span style= "COLOR: #ff0000" >name = "/index.action" class = "Org.springframework.web.servlet.mvc.ParameterizableViewController" > < property name = "ViewName" = "/index.jsp" /> </ bean >
(4) Controller Org.springframework.web.servlet.mvc.AbstractCommandController: Ability to collect client parameters in the form of entities
<name= "/add.action" class= " Com.jyk.springmvc.controller.AdminAction "</bean>
Public classAdminactionextendsabstractcommandcontroller{ Publicadminaction () { This. Setcommandclass (Admin.class); } @OverrideprotectedModelandview handle (HttpServletRequest request,httpservletresponse response, Object obj, bindexception bindexception)throwsException {System.out.println ("Adminaction::handle"); Modelandview Modelandview=NewModelandview (); Admin Admin=NULL; if(objinstanceofAdmin) {Admin=(Admin) obj; } modelandview.addobject ("Username", Admin.getusername ()); Modelandview.addobject ("Gender", Admin.getgender ()); Modelandview.addobject ("HireDate", Admin.gethiredate ()); Modelandview.setviewname ("/jsp/success.jsp"); returnModelandview; }}
SPRINGMVC Mapper, adapter, controller