敏感字符过滤器(filter)
一.敏感字符过滤成(*******)
1. 创建过滤器filter包新建CharFilter类
package filter;
import util.MyRequest01;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Set;
@WebFilter(filterName = "CharFilter",urlPatterns = "/CharServlet")
public class CharFilter implements Filter {
private Properties p = new Properties();
@Override
public void init(FilterConfig filterConfig) throws ServletException {
//初始化,读取文件,存放的;ist中
InputStream stream=filterConfig.getServletContext().getResourceAsStream("/WEB-INF/text.txt");
InputStreamReader is=null;
BufferedReader reader=null;
try {
is=new InputStreamReader(stream,