<!--
Configuring a non-annotated processor adapter: Executing the processor according to the specified rules
-
<!--1. Simplecontrollerhandleradapter: Fits all processors that implement the Org.springframework.web.servlet.mvc.Controller interface--
<bean class= "Org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" ></bean>
(Processor notation:
public class Hellocontroller implements Controller {
@Override
Public Modelandview HandleRequest (httpservletrequest request, httpservletresponse response) throws Exception {
Modelandview Mav = new Modelandview ();
Data, equivalent to Request.setattribute ();
Mav.addobject ("message", "Hello, controller Processor");
Specify return view
Mav.setviewname ("main.jsp");
return MAV;
}
}
)
<!--2. Httprequesthandleradapter: Compatible with all processors that implement the Org.springframework.web.HttpRequestHandler interface, which can coexist--
<bean class= "Org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" ></bean>
(Processor notation:
public class HelloController2 implements Httprequesthandler {
@Override
public void HandleRequest (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {
Request.setattribute ("message", "Hello, controller processor _2....httprequesthandler");
Request.getrequestdispatcher ("/main.jsp"). Forward (request, response);
}
}
)
<!--
Configure a non-annotated processor mapper: Configure the mapping of the URL address to the processor
-
<!--1. Beannameurlhandlermapping: Matches the bean's Name property value according to the URL address--
<bean class= "Org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" ></bean>
<!--2. Simpleurlhandlermapping: Matches the bean's ID attribute value based on the URL address, which is an enhanced version of mode one, which can coexist--
<bean class= "Org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
<property name= "Mappings" >
<props>
<prop key= "/hello11.action" >helloController</prop><!--key:url address Value:bean id attribute value--
<prop key= "/hello22.action" >helloController2</prop>
</props>
</property>
</bean>
Spring mvc--Adapter and Mapper (non-annotated)