springmvc的拦截器,怎么设置不拦截的url

2024-11-30 06:49:26
推荐回答(2个)
回答(1):

这是我的拦截器






粗颂/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;
}
}

回答(2):