Home  >  Article  >  Java  >  Solution to java get garbled problem

Solution to java get garbled problem

尚
Original
2019-12-05 10:31:432860browse

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"))     

garbled characters in post request:

Solution Method: Add

response.setCharcacterEncoding("utf-8")

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!

Statement:
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