JSP display Chinese problem solution _jsp programming

Source: Internet
Author: User
Tags locale
These two days under the Win98 apache1.3.9 plus Jserv and gnujsp1.0,jdk1.2.2,jsdk2.0
Found that Chinese can not display correctly. Either garbled or wrong.
After the Netizen reminds, summed up the following several methods.
1: Modify locale: Select locale in the control plate, set to English (United States). nbsp
And then back up. Everything is normal.
2: Add a statement to the JSP page:
<%@ page contenttype= "text/html;charset=gb2312"%>?
The 琷 SP display is normal.
3: Add code options when compiling the servlet and JSP. Compiling the servlet using
Javac-encoding iso8859_1 Myservlet.java
In the JSP's zone configuration file. Modify the compilation parameters to:
Compiler=builtin-javac-encoding Iso8859_1
After using this method, you will not need to make any other changes to the normal display of Chinese.
4: The most soil method, in the servlet source program to add code transformation statements. Such as
try{
Out.println (New String ("I Love You"). GetBytes ("GBK"), "Iso8859_1")
}
catch (Unsupportedencodingexception e)
{
.......
}
Use this method must pay attention to capture unsupportedencodingexception
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.