------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------
Maybe we've seen one way before. http://localhost:8080/Project name/Background servlet?actionname=login&uname=admin&upwd=123
In this way the servlet is dispatched and the parameters are passed, what am I going to express here? It is? You can stitch the contents back,
So, the parametermethodnameresolver here is to access the method name in this way
Let's talk about the case use step
One, define the parametermethodnameresolver parameter method name Resolver
Second, inject the above defined method name resolver into the bean of the processor you define
Third, in the processor mapper simpleurlhandlermapping the key value of the access, from/* to a specific value, no longer wildcard way
Case Source
Processor class
Package Cn.dawn.day05multiactioncontroller;import Org.springframework.web.servlet.modelandview;import Org.springframework.web.servlet.mvc.multiaction.multiactioncontroller;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.HttpServletResponse;/** * Created by Dawn on 2018/3/23.*/ Public classMymultiactioncontroller extends multiactioncontroller{ PublicString Dofirst (httpservletrequest httpservletrequest, HttpServletResponse httpservletresponse) throws Exception { Modelandview Me=NewModelandview (); Me.setviewname (" First"); return " First"; } PublicModelandview Dosecond (httpservletrequest httpservletrequest, HttpServletResponse HttpServletResponse) throws Exception {Modelandview me=NewModelandview (); Me.setviewname ("Second"); returnme; }}
In your own defined XML file: (three steps)
<?xml version="1.0"encoding="UTF-8"? ><beans xmlns="Http://www.springframework.org/schema/beans"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"Xmlns:mvc="Http://www.springframework.org/schema/mvc"xsi:schemalocation="Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/MVC http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!--Configuring Bean processors--<bean id="Mymultiactioncontroller" class="Cn.dawn.day05multiActioncontroller.MyMultiActionController"><!--The second step, inject the parameter method name Resolver--<property name="Methodnameresolver" ref="Parametermethodnameresolver"></property> </bean> <!--view Resolver-<beanclass="Org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"Value="/"></property> <property name="suffix"Value=". JSP"></property> </bean><!--First step, parameter method name Resolver--<bean id="Parametermethodnameresolver" class="Org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver"> <!--This actionname is a URL question mark? The back equals sign = The parameter on the left----<property name="paramname"Value="ActionName"></property> </bean> <beanclass="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <!--the first way--<property name="UrlMap"> <map><!--step three, change to/* here , not the kind that was written before-- <entry key= "/dofirst" > <value>mymultiactioncontroller< ;/value> </entry> </map> </property> </bean></be Ans>
According to this configuration method, your Access URL is HTTP://IP address: The Tomcat port number/project name/Processor mapper with the key value? Actionname= the method name in your processor
Note Check that you have none of my above first.jsp and second.jsp pages, and that Web. XML does not have to be referenced on the last file you wrote
Parametermethodnameresolver parameter Method name resolver in SSM-SPRINGMVC-11:SPRINGMVC