Question about passing Chinese characters in the url of the jsp page

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.