扫码关注官方订阅号
xml <!-- 配置拦截器 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/list" /> <mvc:mapping path="/list/" /> <bean class="com.web.interceptor.AppInterceptor"></bean> </mvc:interceptor> </mvc:interceptors>
xml
<!-- 配置拦截器 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/list" /> <mvc:mapping path="/list/" /> <bean class="com.web.interceptor.AppInterceptor"></bean> </mvc:interceptor> </mvc:interceptors>
如果我只想拦截 /list/ 的 GET 请求可以吗?
/list/
GET
走同样的路,发现不同的人生
配置时把要处理的请求类型传递给 AppInterceptor, 然后在 AppInterceptor 的preHandle方法里直接判断是否处理。
获取当前请求类型使用 String method = request.getMethod();
指定具体的方法名,然后get方法和post方法用方法名区分开
springmvc可以的,可以通过注解窄化拦截的请求。 例如: @RequestMapping(value="/list", method = {RequestMethod.GET})
PHP学习
技术支持
返回顶部
配置时把要处理的请求类型传递给 AppInterceptor, 然后在 AppInterceptor 的preHandle方法里直接判断是否处理。
获取当前请求类型使用 String method = request.getMethod();
指定具体的方法名,然后get方法和post方法用方法名区分开
springmvc可以的,可以通过注解窄化拦截的请求。
例如:
@RequestMapping(value="/list", method = {RequestMethod.GET})