处理器映射器HandlerMapping:BeanNameUrlHandlerMapping、SimpleUrlHandlerMapping
【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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
">
<!-- 处理器映射器HandlerMapping(根据请求找相应的处理器) -->
<!-- BeanNameUrlHandlerMapping(默认) -->
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<bean name="/login.do" class="com.athl.Controller.MyController" />
<!-- SimpleUrlHandlerMapping -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<!-- 方法一 -->
<property name="mappings">
<props>
<prop key="/login.do">myController</prop>
<prop key="/getAll.do">myController</prop>
<prop key="/delete.do">myController</prop>
</props>
</property>
<!-- 方法二 -->
<property name="urlMap">
<map>
<entry key="/login.do" value="myController" />
<entry key="/getAll.do" value="myController" />
<entry key="/delete.do" value="myController" />
</map>
</property>
</bean>
<bean id="myController" class="com.athl.Controller.MyController" />
</beans>