In webwork, forms submitted using the get method usually contain garbled characters in Chinese. This problem does not occur in post mode...
This problem took me one day and finally solved it by searching for some materials.
My development environment is webwork + velocity, and the encoding is UTF-8
1. Set UTF-8 in velocity. Properties
Input. Encoding = UTF-8
Output. Encoding = UTF-8
Default. contenttype = text/html; charset \ = UTF-8
2. encoding is also set in webwork. properties:
Webwork. i18n. Encoding = UTF-8
3. The form on the page is set to get. When prompted, the string "% E4 % B8 % ad % E5 % 9B % BD" (China) will appear)
In Java, you can use system. Out. println (urlencoder. encode ("China", "UTF-8") to get this encoding.
4. In the action to obtain form data
For example, the content of the submitted form is aa. Action? Keyword = % E4 % B8 % ad % E5 % 9B % BD
Webwork will automatically include the form keyword attribute s to the variable keyword. In this case, it will be garbled to directly read the keyword.
Use keyword = new string (keyword. getbytes ("ISO-8859-1"), "UTF-8"); convert it to get the correct Chinese.