web.xml的配置
老师,配置拦截器的时候记得讲web,xml文件配置
老师,配置拦截器的时候记得讲web,xml文件配置
2016-04-24
<servlet>
<servlet-name>xxx</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>xxx</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<mvc:interceptors> <mvc:interceptor> <!-- 指定该拦截器对哪些请求拦截 --> <mvc:mapping path="/**"/> <!--指定哪些请求放过不拦截--> <mvc:exclude-mapping path="/login.form"/> <mvc:exclude-mapping path="/tologin.form"/> <!-- 指定拦截器组件 --> <bean class="org.tarena.web.interceptor.LoginInterceptor"/> </mvc:interceptor> </mvc:interceptors>
举报