spring mvc拦截器配置

	<!-- springMVC 拦截器 -->
	<mvc:interceptors>
		<mvc:interceptor>
			<mvc:mapping path="/*"/>
			<bean class="com.app.interceptor.AppHandleRequestInterceptor"></bean>
		</mvc:interceptor>
	</mvc:interceptors>

原先是spring-mvc.xml这样配置的,但访问地址:http://localhost:8080/myproject/book/bookList时,并没有进入拦截器。

如果是地址:http://localhost:8080/myproject/index时,可以进入。

修改1:

<mvc:mapping path="/"/>

拦截都失败。

修改2:

<mvc:mapping path="/*/*"/>

二者都可以,但若改成http://localhost:8080/myproject/index/book/bookList就不行了。

修改3

<mvc:mapping path="/**"/>

都可以。

根据需求,选择拦截路径,项目中有规定就选的第二种。

猜你喜欢

转载自wwy0612.iteye.com/blog/2374360