1. Add the following content to struts. xml:
<Constant name = "struts. i18n. encoding" value = "gb18030"/>
2. Solve Chinese garbled characters in struts 2.0. Configure the following in the Struts. properties file.
struts.i18n.encoding=gb2312 |
Struts. i18n. encoding is used to set the default encoding for Web applications, while gb2312 specifies the default encoding.
This method solves the problem of Chinese garbled characters after the form is submitted. In this case, the method attribute value of the form must be post. If the form implemented by the form tag in struts 2.0 is used, the method attribute can be omitted. The default value is post; if the form is implemented through the form identification of the original HTML language, you need to set the method attribute and assign the value to post.
3.
If the value of a parameter passed by a hyperlink is a Chinese character, the following transcoding operation must be performed after the parameter value is obtained in the Action Service controller. Otherwise, the obtained value is garbled.
String sqlvalue = request. getparameter ("sqlvalue"); // obtain the parameter sqlvalue = new string (sqlvalue. getbytes ("ISO-8859-1"), "gb2312"); // perform transcoding operations