Garbled characters occur when JSP passes Chinese parameters through address addresses

Source: Internet
Author: User
Tags jboss
Chinese garbled characters have plagued JSP ProgramClerk, I often see this situation during programming;
After a piece of writing experience and absorbing his experience, the situation of "garbled characters in passing Chinese parameters through address addresses in JSP" is summarized as follows;
(1) In tomcat, because the pass by get method in the past, Tomcat will be converted to the original by ISO-8859-1 (Address Bar default) encoding
UTF-8 form, if read by UTF-8, no need to convert;
The response. sendredirect () format is:
Response. sendredirect ("*****. jsp? Message = "+ java.net. urlencode. encode (" Chinese "));
(2) when using the previous method in JBoss, we still cannot obtain the correct Chinese;
You also need to convert the obtained encoding as follows:
String MSG = new string (request. getparameter ("message"). getbytes ("ISO-8859-1"), "UTF-8 ");
Personal guess: the service may not automatically convert the ISO-8859-1 code to the UTF-8 when getting the variable, so we need to convert it manually;
However, I still have some questions. Isn't JBoss embedded with tomcat?
_---------------------------------------------------------------------
Of course, there are still many solutions to coding problems;
You can find them online.
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.