Complete struts development under eclispe to solve the garbled Problem

Source: Internet
Author: User
I am very annoyed by the Chinese issue of struts resource files. How can I make the quotas Chinese ??? Or some of the documents you cannot understand. Let's not talk much about it. Let's look at the following key points:

There are three main problems:

1. If the value in struts Chinese source files is Chinese, garbled characters are displayed.

Solution: Use the Eclipse plug-in properties Editor

Update site http://propedit.sourceforge.jp/eclipse/updates/ (recommended for automatic updates)

Steps:

Find and install help/software updates/Under Eclipse/select second/new remote site/name random write URL input http://propedit.sourceforge.jp/eclipse/updates/

2. Enter Chinese characters in the text field to display garbled characters

Solution: Use the servlet Filter

You can use filters. setcharacterencodingfilter under tomcat to add the corresponding servlet_examples configuration in tomcat in your web. xml configuration. (You can configure them yourself !)

The configuration is as follows:

Setcharacterencoding
Filters. setcharacterencodingfilter
Encoding
GBK
Setcharacterencoding
*. Do
3. Read garbled characters from some databases

Solution: recode the part you want to display as Chinese

For example, while (Rs. Next ())
{
String col1 = Rs. getstring (1 );
String col2 = Rs. getstring (2 );
String col3 = Rs. getstring (3 );
Float col4 = Rs. getfloat (4 );
// Convert character encoding
Col1 = new string (col1.getbytes ("ISO-8859-1"), "gb2312 ");
Col2 = new string (col2.getbytes ("ISO-8859-1"), "gb2312 ");
Col3 = new string (col3.getbytes ("ISO-8859-1"), "gb2312 ");
}

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.