9)FilterConfig的用法:
FilterConfig可以从web.xml当中取得一些有关Filter参数,当Web应用启动时就可以获得了。
例 1.2.9
package com;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
public class MarkToWinFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
}
protected FilterConfig filterConfig;
public void init(FilterConfig fConfig) throws ServletException {
this.filterConfig = fConfig;
System.out.println(filterConfig.getInitParameter("name"));
}
}
更多请看:https://blog.csdn.net/qq_44638460/article/details/104099777