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"));
}
}
FilterConfig的用法是什么?
最新推荐文章于 2023-01-17 08:48:13 发布