FIlter配置全站编码有一种方法是重写getParameter方法,也就是继承HttpServletRequestWrapper在重写getParameter方法,还有一种就是如下:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 将requese进行强转
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
// 得到参数提交方式
String method = req.getMethod();
// 分为Get和Post两种方式进行处理
if(method.equalsIgnoreCase("post")) {
System.out.println("采用的是Post请求方式...");
// post请求方法,直接可以进行设置
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
} else {
System.out.println("采用的是Get请求方式...");
// get 请求方法,对于请求的参数的进行改变设置字符集
resp.setContentType(