引入:
http://blog.csdn.net/qq_37791322/article/details/79631164
点击打开链接
1.在引入文章的基础之上修改springmvc.xml配置文件
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
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/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="top.wyyblog.handlers"></context:component-scan>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/my_*.do" value-ref="myController"></entry>
</map>
</property>
</bean>
<!-- 注册方法名称解析-->
<bean id="propertiesMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/my_first.do">doFirst</prop>
<prop key="/my_second.do">doSecond</prop>
</props>
</property>
</bean>
<!-- 注册处理器 -->
<bean id="myController" class="top.wyyblog.handlers.MyController2">
<property name="methodNameResolver" ref="propertiesMethodNameResolver"></property>
</bean>
</beans>
2.测试
![](//img-blog.csdn.net/20180320204801572?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3FxXzM3NzkxMzIy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
![](//img-blog.csdn.net/20180320204821386?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3FxXzM3NzkxMzIy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)