|
filter can be configured with parameters,
You can configure a parameter called exclusion, separated by commas, and the path recorded in it. Although it enters the filter, it is not processed.
such as
<filter>
.....
<init-param>
<param-name> exclusions </ param-name>
<param-value> /, /index.jsp, /login.do, /logout.do, /test.jsp </ param-value>
</ init-param>
</ filter>
filter
public class MyFilter implements Filter {
Set exclusions;
public void init (FilterConfig filterConfig) throws ServletException {
super.init (filterConfig);
String exclu = filterConfig.getInitParameter ("exclusions");
exclusions = new HashSet ();
// split operations
}
public void doFilter (ServletRequest request,
ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
if (! exclusions.contains (httpRequest.getServletPath ())) {
// original operation
}
} |
|