xml
如果我只想拦截 /list/
的 GET
请求可以吗?
springmvc可以的,可以通过注解窄化拦截的请求。
例如:
@RequestMapping(value="/list", method = {RequestMethod.GET})
指定具体的方法名,然后get方法和post方法用方法名区分开
配置时把要处理的请求类型传递给 AppInterceptor, 然后在 AppInterceptor 的preHandle方法里直接判断是否处理。
获取当前请求类型使用 String method = request.getMethod();