In the servlet learning, when the Web page input in English, although the Get method and the Post method can correctly pass the data to the data, but when the input box input in Chinese, when the background program to receive data, there will be garbled problems. This can be done by setting its encoding format, but not simply by setting it to "Utf-8", but in a variety of ways.
When committed with get, it needs to be set to new String (Name.getbytes ("iso-8859-1"), "Utf-8"), for example:
String name = Req.getparameter ("UserName");
String userName = new String (Name.getbytes ("iso-8859-1"), "Utf-8");
In this way, it is good to pass the Chinese characters correctly to the background data.
When using post to submit, it needs to be set to Req.setcharacterencoding ("Utf-8"), which is directly before the background data to pass the data before adding OK.
7.15 about resolving the get and post garbled problems of Javaweb background resolution Servlet