js| Solutions | problems | show | Chinese solutions for JSP Chinese display problems the following methods are summarized: 1. Add a statement to the JSP page: <%@ page contenttype= "text/html;charset=gb2312"%> The Chinese display is normal. 2, for the text box from the Web page through string parameter = Request.getparameter ("parameter"), the way to obtain the string, are 8859_1 encoding, if you want to display it on the Web page must be used parameter = New String (parameter.getbytes ("8859_1"), "gb2312") for conversion, both Windows and Linux are the same. An easy way to do this is to use Request.setcharacterencoding ("GB2312") before the GetParameter () method gets the arguments, and to convert the submitted information to GB2312 encoding. 3, but for the problem of writing data to the database, the way is different: under Windows, you must use the string conversion and then insert the database, and Linux does not need to, but directly to the 8859_1 encoded characters inserted. If you read the data from the database, for Windows because it has been converted at the time of insertion, it is already gb2312 when it is displayed on a Web page, and the data in MySQL on Linux is 8859_1 so that it is encoded. 4. If you give a string variable a value of a Chinese string, the display on the Web page does not require character conversion when you remove it, but if you want to do a character comparison under Linux, you will also need to make the character parameter = new String ( Conversion of Parameter.getbytes ("gb2312"), "8859_1"). 5, the Yangtze River Power website to solve the Chinese problem is: 1 in the catalina.sh file in the relevant location add the following line-DFILE.ENCODING=GBK \ 2) Add the following two lines to the front of each JSP file <%@ page contenttype= text/html; CHARSET=GBK "%><%request.setcharacterencoding (" GBK "),%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.