I have been an intern in the company for 8 months, and I have always been working on android and h5. However, I found that I don’t know what to do when making programs or even a little service, so I recently started to learn java. I don’t know if it is because I have learned too much about frameworks. Now, it seems that the springmvc framework is much simpler than before. Here I am going to start learning from hibernate. After all, data is fundamental. First of all, I use hibernate+servlet, but when passing parameters from the jsp page to the servlet Chinese characters have been garbled. I tried many methods and finally solved it.
First, first check the encoding of the project and the encoding of the jsp page
Second, modify the server.xml file under tomcat
Third, configure the project filter
Fourth, modify the value-passing encoding and transfer encoding in the servlet
request.setCharacterEncoding("UTF-8");//value-passing 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");
Okay, I used the above four methods but failed to solve my problem. I used the fifth method. To solve the problem, I didn’t write down the detailed steps here. I just talked about the general modification method. You can Baidu for the detailed steps of the method. If nothing happens, it can be solved.
The solution to the problem of jsp passing parameters and servlet receiving Chinese garbled characters above is all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support the PHP Chinese website.
For more jsp parameter-passing solutions to the problem of servlet receiving Chinese garbled characters, please pay attention to the PHP Chinese website for related articles!