A solution to the problem of Chinese garbled code received by the JSP reference servlet _jsp programming

Source: Internet
Author: User

Internship in the company for 8 months, has always been doing Android and H5, but found that the program does not even a little service should do, so recently began to learn Java, do not know because the framework is much more, now look at the SPRINGMVC frame than before look too much simpler, Here I am ready to start learning from Hibernate, after all, the data is at all, first I use the Hibernate+servlet, but in the JSP page to the servlet when the Chinese has been garbled, I tried a lot of methods, and finally resolved.

First, see the coding of the project first, the Code of the JSP page

Second, modify the Server.xml file below Tomcat

Third, project configuration filter

Finally , change the encoding and transmission code in the servlet

Request.setcharacterencoding ("UTF-8");//pass-value encoding
Response.setcontenttype ("Text/html;charset=utf-8");//Set transfer encoding


String Username=request.getparameter ("username");
String Username1=new string (username.getbytes ("iso-8859-1"), "Utf-8");

Well, I used the above four kinds of can not solve my problem, using the fifth kind of solution, where I did not write the detailed steps, just said the general modification method, we can be a detailed method of Baidu steps, no accident can be resolved.

The above JSP reference servlet to receive the Chinese garbled Problem solution is small series to share all the content, I hope to give you a guide, but also hope that we support cloud habitat community.

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.