WEB-INF目录下面建一个ascweb-servlet.xml文件,其实这个文件的命名就是Web.xml中servlet-name的名字加-servlet.xml.其文件内容如下:
<?xml version="1.0" encoding="UTF-8" ?>标签:xml,www,http,spring,springframework,mvc,org,servlet,schema From: https://blog.51cto.com/u_3871599/6138467
<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">
<mvc:annotation-driven />
<context:component-scan base-package="com.asm" />
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"></bean>
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter"></bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/pages/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!-- ********************* simpleUrlHandlerMapping *************************** -->
<bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/hello.do">helloWord</prop>
<prop key="/regControl.do">regControl</prop>
<prop key="/regControl1.do">regControl1</prop>
<prop key="/list.do">userManagerController</prop>
<prop key="/add.do">userManagerController</prop>
<prop key="/edit.do">userManagerController</prop>
</props>
</property>
</bean>
<bean id="beanNameUrlHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<!-- ********************* springMethodNameResolver *************************** -->
<bean id="springMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/list.do">list</prop>
<prop key="/add.do">add</prop>
<prop key="/edit.do">edit</prop>
</props>
</property>
</bean>
<!-- ********************* Controller *************************** -->
<bean id="helloWord" class="com.asm.controller.HelloWord"></bean>
<bean id="regControl" class="com.asm.controller.RegControl"></bean>
<bean id="regControl1" class="com.asm.controller.RegControl1">
<property name="commandClass" value="com.asm.pojo.User"></property>
</bean>
<bean id="userManagerController" class="com.asm.controller.UserManagerController">
<property name="methodNameResolver" ref="springMethodNameResolver"></property>
</bean>
<bean name="/message.do" class="com.asm.controller.MessageController"></bean>
</beans>