At the beginning of the creation of the SPINGMVC project, we only need to configure the front controller and the processor, the other three systems will be configured by default, we can also configure
First look at configuring the processor mapper, the system default
Configuring in Springmvc.xml
Another way to configure this is to configure the same in Springmvc.xml, using the Simpleurlhandlermapping class
<beanclass="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <! – Mode One –> <property name="Mappings"> <props> <prop key="/hello">firstController</prop> </props> </property>Mode two<property name="UrlMap"> <map> <entry key="/hello"Value="Firstcontroller"></entry> </map> </property> </bean>
When this configuration is accessed, the value of the key can be accessed directly.
Two. About Abstractcontroller
Define a class that allows him to inherit Abstractcontroller
Package Demo03abstractcontroller;import Org.springframework.web.servlet.modelandview;import Org.springframework.web.servlet.mvc.abstractcontroller;import Org.springframework.web.servlet.mvc.Controller; Import Javax.servlet.http.httpservletrequest;import javax.servlet.http.HttpServletResponse;/** * Created by mycom on 2018/3/18.*/ Public classFirstcontroller extends Abstractcontroller {protectedModelandview handlerequestinternal (httpservletrequest httpservletrequest, HttpServletResponse HttpServletResponse) throws Exception {Modelandview mv=NewModelandview (); Mv.setviewname ("Index"); returnMV; }}
In the configuration file Springmvc.xml
<!--registered Processor-- <beanid= "/firstcontroller"class=" Demo03abstractcontroller.firstcontroller" > <property name=" Supportedmethods "value="post,get"></property> </bean>
SPRINGMVC (iii) configuration of processor Mapper and use of Abstractcontroller