我创建了一个包装类,通过将所有输入参数分配到数组中来验证它们。我收到Filter类的请求。 getParameterValues不能用于将请求参数放入数组中。
public class XSSRequestWrapper extends HttpServletRequestWrapper {
public XSSRequestWrapper(HttpServletRequest servletRequest) {
super(servletRequest);
}
以下代码正常
public String getParameter(String name) {
// TODO Auto-generated method stub
return super.getParameter(name);
}
以下根本不起作用
public String[] getParameterValues(String name) {
// TODO Auto-generated method stub
return super.getParameterValues(name);
}
以下是filter.java
//@WebFilter("/filter")
public class filter implements Filter {
public filter() {
// TODO Auto-generated constructor stub
}
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(new XSSRequestWrapper((HttpServletRequest) request), response);
}
public void init(FilterConfig fConfig) throws ServletException {
// TODO Auto-generated method stub
}
}