When jspservlet is used for webpage development, if the request is used. setCharacterEncoding ("UTF-8"); and response. setContentType ("text/html; charset = UTF-8"); method to set the character set, can only work for post requests, because such settings can only work for the request message body. The get request parameter is placed in the Request Header, that is, the url. Therefore, this setting is invalid.
If the url contains Chinese characters, such as <a href = "server/upload? Command = I am Jing yuwang "> Use get to upload Chinese </a>, in the parameter, the browser uses its default character set to transcode and then submit it to the background (of course, the parameter after transcoding is no longer in Chinese ). The background servlet receives this parameter, String command = request. getParameter ("command"), where the parameter in the command is a character encoding of A ISO-8859-1. If the code is converted to command = new String (command. getBytes ("ISO-8859-1"), "GBK"); at this time the command is a front-end passed over the Chinese, print System. out. println ("The command is:" + command); The complete Chinese