Chinese garbled characters displayed in jsp, and Chinese parameters on different pages are garbled

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>

1. Both charset and pageEncoding in the jsp page are utf-8, so there is no problem in writing Chinese in the jsp page.

2. When obtaining Chinese parameter values, in the case of POST request, before using request, set request.setCharacterEncoding("UTF-8"); solve that the obtained Chinese is not garbled information. When GET request, there is a problem with tomcat, the default transmission code is ISO-8859-1, there is a problem with Chinese, the solution, find tomcat-->conf--->server.xml--->:

<Connector port="8080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443" useBodyEncodingForURI="true"/>

Guess you like

Origin blog.csdn.net/qq_39655510/article/details/111084217