get请求受Tomcat编码影响导致乱码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010686469/article/details/76422670

一位同事遇到一个问题,分页查询出现乱码现象。

1、页面输入查询条件、点击查询

2、显示查询结果,都是正常编码

3、页面点击分页按钮下一页

4、页面显示空白

5、后台查日志发现,分页时传入的查询条件是乱码,导致查不出数据

解决过程:

1、查看查询配置:

Struts代码:


<action name="quickAddCustomerInfoQuery" class="defaultValueListAction">
<param name="queryId">quickAddCustomerInfo</param>
<result>/jsp/quickAddCustomerInfo/quickAddCustomerInfoQueryResult.jsp</result>
</action>


valuelist代码只是很简单的查询语句,没有什么业务逻辑


2、查看页面编码:

  1. Connection:
    keep-alive
  2. Content-Encoding:
    gzip
  3. Content-Language:
    zh-CN
  4. Content-Type:
    text/html;charset=UTF-8
  5. Date:
    Mon, 31 Jul 2017 03:03:47 GMT
  6. Server:
    nginx
  7. Transfer-Encoding:
    chunked
3、查看后台拦截器代码:

            request.setCharacterEncoding("UTF-8");
            response.setCharacterEncoding("UTF-8");
filterChain.doFilter(request, response);

4、查看请求类型:

  1. Request Method:
    GET
  2. Status Code:
    200 OK
5、设置Tomcat编码方式:


<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>


6、重启Tomcat,问题解决

猜你喜欢

转载自blog.csdn.net/u010686469/article/details/76422670