|
3Java金币
自己编写了一个简单的特殊字符过滤器,但是报错,代码如下:
package com.wsf;
import java.io.IOException;
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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OutputReplaceFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest) request;
HttpServletResponse res=(HttpServletResponse) response;
String username=req.getParameter("id");
System.out.print("33333333333333");
username=username.replaceAll("bai","en");
req.setAttribute("username", username);
chain.doFilter(request,response);
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
报错的是username=username.replaceAll("bai","en");求告知
|
|