web中Filter通过<init-param>添加参数。
web。xml中的配置:
<filter>
<filter-name>AuthFilter</filter-name>
<filter-class>com.interact.filter.AuthFilter</filter-class>
<init-param>
<param-name>ignores</param-name>
<param-value>getWorkOrderReqRow,todayWorkOrder,login2.do,queryFeedBack.do,addFeedBack.do,validatePermit.do</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>AuthFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
后台代码:直接添加属性,通过get、set方法进行获取以及设置。通过"this."调用
public class AuthFilter implements Filter {
private String ignores;
public String getIgnores() {
if(this.ignores == null){
return "";
}
return ignores;
}
public void setIgnores(String ignores) {
this.ignores = ignores;
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
this.ignores = filterConfig.getInitParameter("ignores");
}
public boolean isIgnore(String uri){
for(String s : this.getIgnores().split(",")){
if(uri.contains(s)){
return true;
}
}
return false;
}
}
后续继续研究......
https://blog.csdn.net/yuzhiqiang_1993/article/details/81288912