The other steps are not introduced
In most cases, handlermapping processing is done using a annotation-based approach, based on an understanding of the process, using XML-based configuration of a handlermapping
[HTML]View PlainCopy
- <Bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
- <property name="mappings">
- <props>
- <prop key="HI">test</prop>
- </Props>
- </Property>
- </Bean>
- <Bean id="test" class="Springmvc01.testcontroller"></bean>
Because annotation is not used, the TestController is injected into it, and when there is a hi this URL, it will be processed using TestController;
TestController inherits the controller this interface, implements the HandleRequest this method, here also can only deal with a URL, a controller corresponds to a URL, but the cost is relatively small;
[Java]View PlainCopy
- Import Javax.servlet.http.HttpServletRequest;
- Import Javax.servlet.http.HttpServletResponse;
- Import Org.springframework.web.servlet.ModelAndView;
- Import Org.springframework.web.servlet.mvc.Controller;
- Public class TestController implements Controller {
- @Override
- Public Modelandview HandleRequest (httpservletrequest arg0,
- HttpServletResponse arg1) throws Exception {
- System.out.println (12);
- return null;
- }
- }
Some introduction to
Springmvc and handlermapping basic flow based on XML