dispatcherServlet-servlet.xml(SSM maven 项目)
<?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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!--SpringMVC的配置文件,包含网站跳转逻辑的控制 、 配置 默认规则 use-default-filters=" false" --> <context:component-scan base-package="xyz.sun" use-default-filters="false"> <!--只扫描控制器 所有标有Controller 注解的都是控制器--> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:include-filter> </context:component-scan> <!--配置视图解析器,方便页面返回--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views"></property> <property name="suffix" value=".jsp"></property> </bean> <!--两个标准配置--> <!--将springmvc不能处理的请求交给tomcat--> <mvc:default-servlet-handler /> <!-- 能支持springmvc 更高级的一些功能 JSR303校验 快捷Ajax请求 映射动态请求 --> <mvc:annotation-driven /> </beans>