From f508d564b047c1e6bad2a78029a4c064c580c97d Mon Sep 17 00:00:00 2001 From: wxlzmt Date: Fri, 13 Jul 2018 14:56:28 +0800 Subject: [PATCH] update --- .../com/ect/imp/web/CharacterEncodingFilter.java | 13 +++++++------ src/main/webapp/check.jsp | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/ect/imp/web/CharacterEncodingFilter.java b/src/main/java/com/ect/imp/web/CharacterEncodingFilter.java index 0290fa4..6592d24 100644 --- a/src/main/java/com/ect/imp/web/CharacterEncodingFilter.java +++ b/src/main/java/com/ect/imp/web/CharacterEncodingFilter.java @@ -18,9 +18,9 @@ public class CharacterEncodingFilter implements javax.servlet.Filter { private String defaultEncoding = "UTF-8"; - /**释义:是否过滤POST请求的参数.*/ + /**释义:是否过滤POST请求的参数.*/ private boolean enableFilterPostMethod = true; - /**释义:是否过滤GET请求的参数.*/ + /**释义:是否过滤GET请求的参数.*/ private boolean enableFilterGetMethod = true; @Override @@ -31,8 +31,9 @@ public void destroy() { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { // 处理请求乱码 - if (enableFilterPostMethod || enableFilterGetMethod) { - HttpServletRequest httpServletRequest = (HttpServletRequest) request; + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + String method = httpServletRequest.getMethod(); + if ((method.equalsIgnoreCase("POST") && enableFilterPostMethod) || (method.equalsIgnoreCase("GET") && enableFilterGetMethod)) { HttpServletRequest myRequest = new MyRequest(httpServletRequest); filterChain.doFilter(myRequest, response); } else { @@ -89,7 +90,7 @@ public Map getParameterMap() { } // 先获得请求方式 String method = request.getMethod(); - if (method.equalsIgnoreCase("POST") && enableFilterPostMethod) { // post方式请求 + if (method.equalsIgnoreCase("POST")) { // post方式请求 try { request.setCharacterEncoding(defaultEncoding); this.cachedParameterMap = request.getParameterMap(); @@ -97,7 +98,7 @@ public Map getParameterMap() { } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - } else if (method.equalsIgnoreCase("GET") && enableFilterGetMethod) { // get方式请求 + } else if (method.equalsIgnoreCase("GET")) { // get方式请求 Map parameterMap = request.getParameterMap(); if (!hasEncode) { for (String parameterName : parameterMap.keySet()) { diff --git a/src/main/webapp/check.jsp b/src/main/webapp/check.jsp index eecf8ea..5f04707 100644 --- a/src/main/webapp/check.jsp +++ b/src/main/webapp/check.jsp @@ -208,13 +208,10 @@ hr { remotePort<%=request.getRemotePort() %> remoteUser<%=request.getRemoteUser() %> authType<%=request.getAuthType() %> - isAsyncStarted<%=request.isAsyncStarted() %> - isAsyncSupported<%=request.isAsyncSupported() %> isRequestedSessionIdFromCookie<%=request.isRequestedSessionIdFromCookie() %> isRequestedSessionIdFromURL<%=request.isRequestedSessionIdFromURL() %> isRequestedSessionIdValid<%=request.isRequestedSessionIdValid() %> isSecure<%=request.isSecure() %> - isTrailerFieldsReady<%=request.isTrailerFieldsReady() %> toString<%=request.toString() %>