mvc:interceptor拦截器使用
在spring-mvc.xml里面配置标签
<mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/**"/> <bean class="com.mbfw.interceptor.LoginHandlerInterceptor"></bean> </mvc:interceptor> </mvc:interceptors>
然后编写拦截器代码类LoginHandlerInterceptor的业务逻辑(继承HandlerInterceptorAdapter类)
public class LoginHandlerInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { return true; } }
逻辑自己定义。