赞
踩
<?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" xmlns:context="http://www.springframework.org/schema/context" 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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!--引入Spring配置文件--> <import resource="classpath:applicationContext.xml"/> <!--配置SPringMVC注解解析器--> <mvc:annotation-driven/> <!--放行静态资源页面--> <mvc:default-servlet-handler/> <!--配置视图解析器,页面路径过于复杂,配置前缀和后缀--> <!--<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/user/"/> <property name="suffix" value=".jsp"/> </bean>--> <!--配置拦截器(只能拦截请求,不能拦截具体页面)--> <mvc:interceptors> <mvc:interceptor> <!--拦截什么样的路径 /*:表示拦截所有的一级路径 /**:拦截任意多级路径 /student/get/list/query --> <mvc:mapping path="/**"/> <!--直接放行此请求或页面--> <mvc:exclude-mapping path="/logincheck"/> <!--登录请求放行--> <mvc:exclude-mapping path="/login.html"/> <!--登录页面放行--> <mvc:exclude-mapping path="/static/**"/> <!--静态资源存放位置直接放行(css、js、html)--> <!--拦截器类的全限定名--> <bean class="com.project.SSM.user4crud.interceptors.UserLoginInterceptors"/> </mvc:interceptor> </mvc:interceptors> </beans>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!--web.xml中配置SpringMVC的前端控制器,拦截所有请求--> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!--关联springMVC的配置文件--> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springmvc.xml</param-value> </init-param> <!--tomcat服务器启动时,完成控制器初始化,正整数即可--> <load-on-startup>1</load-on-startup> </servlet> <!--配置前端控制器的映射文件--> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <!--/代表拦截所有静态资源页面,可在mvc.xml中配置放行所有静态资源(SpringMVC无法处理静态页面), --> <url-pattern>/</url-pattern> </servlet-mapping> <!--web.xml中配置SpringMVC的编码过滤器 --> <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <!--设置编码格式--> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <!--设置request、response作用域强制使用此编码格式--> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <!--配置过滤器映射文件--> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>/login.html</welcome-file> </welcome-file-list> </web-app>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。