Home > Java > JavaBase > body text

Solution to java get garbled problem

Release: 2019-12-05 10:31:43
Original
2817 people have browsed it

Solution to java get garbled problem

java http request garbled problem: (recommended: java video tutorial)

get request garbled code:

Solution: After obtaining the string in the background, convert the encoding, such as the common encoding ISO-8859-1, the code is as follows

String name = request.getParameter("name");
name=new String(name.getBytes("ISO-8859-1","utf-8"))     
Copy after login

garbled characters in post request:

Solution Method: Add

response.setCharcacterEncoding("utf-8")
Copy after login

to the servlet page. For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of Solution to java get garbled problem. For more information, please follow other related articles on the PHP Chinese website!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!