首先,你的拦截路径需要根据的实际应用场景来定,按照你的拦截配置,我猜测你可能是要拦截HTML/路径下,.html的页面请求,如果这个猜测成立,那么你的配置和CommonInterceptor类需要实现如下几步:
1.修改配置
<mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/HTML/**" /> <bean class="com.staffos.interceptor.CommonInterceptor"></bean> </mvc:interceptor> </mvc:interceptors>
2.implements HandlerInterceptor (@Override 让IDE去帮你完成)
3.重写 preHandle 方法,其中需要你写自己的业务逻辑
Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { //此判断需完善 if(StringUtils.contains(request.getRequestURL().toString(),".html")){ //doBus... return false; //如果需要跳转 } //如果不处理则直接 return true; }
希望能帮到你~
你如何判断没有拦截到?
CommonInterceptor里面是如何实现的?
为何不从根目录起设置?或者用**代替前缀