I passed a value from the address bar in the js Code to the corresponding variable of the action. However, if the variable value is Chinese, in the test output in the action, the question mark is a small problem encountered when the project of an ssh framework was completed a few days ago. This is the case.
The private variable is defined in the action and the get () and set () methods are provided, which should be accessible in js Code. Therefore, I passed a value from the address bar in the js Code to the corresponding variable of the action. However, if the variable value is Chinese, the test output in the action is "?", Chinese characters are still displayed in the address bar of the browser.
I first configured the tomcat configuration file according to some answers on the Internet. Later I thought it might not be a complicated issue, but it should be the encoding issue. Both my myeclipse and project code are set to "UTF-8 ". So I tried to set both the project and myeclipse code to "iso8859-1", or not.
This is not the case, so I took a more direct approach. In the action, convert the obtained variable value (assuming the variable is string ):
The Code is as follows:
String newstring = new String (string. getBytes ("iso8859-1 "));
However, this is useless ~~~~~~ I tried it for a long time and found that my idea is correct, but the appropriate statement should be as follows:
The Code is as follows:
String newstring = new String (string. getBytes ("iso8859-1"), "UTF-8 ");
Ps: I first try to convert it into GBK, and then I find that the word can be displayed, but no one knows it... Sure enough, the support of "iso8859-1" for Chinese is good.