Several methods of solving JSP Chinese display issues
Summarize the following methods:
1. Add a statement in the JSP page:
<% @ Page ContentType = "text / html; charset = GB2312"%> Chinese display is normal.
2, for text boxes from the web page via String Parameter = Request.GetParameter ("parameter"), the string obtained is 8859_1,
If you want to display it on the webpage, you must have to use parameter = new string (Parameter.getbytes), "GB2312"), both of these systems, both of Windows and Linux.
There is a simple way to use Request.setCharacterencoding before getParameter () method, use Request.SetCharacterencoding ("GB2312");
3, but the way to write data into the database, the way to take is different:
Under Windows, you must use this string to convert the database, and the linux is not needed, but the character encoded by 8859_1 is inserted directly.
If the data read from the database, for Windows because it has been converted during insertion, it is already GB2312 when it is read, and when it is displayed on the web page, it is not necessary to do encoding conversion, and the mysql on Linux is required. The data is 8859_1 so that the conversion to be coded.
4. If you give a string variable to a Chinese string value, then when you take it out, the display on the web page does not need to be converted.
But if you want to make characters under Linux, you also need to make parameter = new string (parameter.getbytes ("GB2312", "8859_1").
5. The method of solving Chinese issues in Yangtze River power website is:
1) Add the following line in the relevant location in the Catalina.sh file
-Dfile.encoding = GBK /
2) Add the following two lines in the top of each JSP file.
<% @ page contenttype = "text / html; charset = GBK"%>
<% Request.SetCharacterencoding ("GBK");%>