Baidu says it can be judged manually by req.getURI, but I don"t want to. I don"t think it"s elegant.
Configuration
@WebFilter(filterName = "myFilter", urlPatterns = "/*")
public class MyFilter implements Filter {
@Override
public void init(FilterConfig arg0) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
String cookieToken =CookieUtils.getCookie(req,"token");
String headerToken = req.getHeader("token");
if (TokenUtils.notCorrect(headerToken)){
return;
}
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}