There are three main questions:
1,struts in resource file if value is Chinese, display garbled
Workaround: Use the Eclipse plug-in properties Editor
2, in the text field input Chinese display garbled
Workaround: Use the servlet filter filter
The simplest of these can be borrowed from the filters below Tomcat. Setcharacterencodingfilter in their own web.xml configuration to add Tomcat servlet_examples corresponding configuration (master can be their own match!)
My configuration is as follows:
Setcharacterencoding
Filters. Setcharacterencodingfilter
Encoding
GBK
Setcharacterencoding
*.do
3, read garbled from some database
Solution: Re-encode 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");
}