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
Fifth
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.