Home php教程 PHP开发 Solution to the problem of jsp passing parameters and servlet receiving Chinese garbled characters

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

Dec 29, 2016 pm 05:07 PM

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!


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1672
14
PHP Tutorial
1277
29
C# Tutorial
1257
24