由于springmvc是通过DispatcherServlet来作为入口的,所以其实只要看Servlet不拦截所有后缀的方法。
如果只要拦截特定的几个规则,可以配置一个Filter,在Filter中判断后缀,后缀不对的全给他跳转到404页面去
我拦截器
/yhxx/login.do
/yhxx/toLogin.do
/yhxx/sessionTimeOut.do
其allowUrls拦截
拦截器
private List allowUrls;
public List getAllowUrls() {
return allowUrls;
}
public void setAllowUrls(List allowUrls) {
this.allowUrls = allowUrls;
}
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
String requestUri = request.getRequestURI();
for (String url : allowUrls) {
if (requestUri.endsWith(url)) {
return true;
}
}