A simple solution to the JSP page to pass the value Chinese garbled

Source: Internet
Author: User

Source code, a.jsp to b.jsp value:

a.jsp Page Content:

Name

b.jsp Page Content:

Phenomenon: Chinese garbled, such as "??????"

The workaround is as follows:

Method One:

1. In b.jsp, replace pageencoding= "GB2312" with pageencoding= "Iso8859-1"

Although this b.jsp page display content or garbled, but not the kind of "??????" The garbled, but some special characters

2. Then in the browser to see the menu modified into GB2312 code, then garbled display in Chinese.

3. However, this method is not feasible.

Method Two:

1. In the b.jsp string name=request.getparameter ("name");

String Name=new string (Request.getparameter ("name"). GetBytes ("Iso-8859-1"), "GB2312");

2. Then the display on the page, it is Chinese.

Method Three:

1. It is said to modify the value of Get/post, but this is a prerequisite, if only the get way to modify the post method, the page result or garbled!

2. The premise you must configure the filter, if you just configured the filter, then the value must be the way: Post way is not garbled, if the get way is still garbled!

3. The configuration of the filter, I think we can all have, I will not say

Method Four:

1. It was said that configuring Tomcat's configuration file server.xml this sentence:

port= "8080" maxhttpheadersize= "8192"

maxthreads= "minsparethreads=" maxsparethreads= "75"

Enablelookups= "false" redirectport= "8443" acceptcount= "100"

connectiontimeout= "20000" disableuploadtimeout= "true"/>

Add this sentence: uriencoding= "GB2312"

2. Although it can but have the prerequisite, if you do not configure the filter, it is only configured server.xml files, so only in the form of Get pass value only when it can! When it is the Post method, it is still garbled!

* Then we can see that the post in TOMCAT5 is not the same as the Get pass value

* Someone wants to ask if there is a way to make the value of the pass using Get method or Post method, the following is the method I recommend five *

Method Five:

1. In fact very simple, is the simultaneous implementation of the three methods and implementation of the method four!

2. Is to configure the filter first, and configure the Server.xml file, are set to GB2312 encoding

3. So whether it is post or get way of table conveys value, Chinese will not be garbled!

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.