Home > php教程 > PHP开发 > body text

Solution to the problem of jsp passing parameters and servlet receiving Chinese garbled characters

高洛峰
Release: 2016-12-29 17:07:16
Original
1865 people have browsed it

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!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template