search
HomeJavaJavagetting StartedWhat should I do if java returns garbled characters?

What should I do if java returns garbled characters?

What should I do if java returns garbled characters?

The solution to the problem that the java server returns Chinese garbled characters

Recommended tutorial: "java learning"

Chinese transmitted from the java server Displayed as a question mark "?", for example, the value of the following name:

The reason is that the charset of the server response is not set to "UTF-8", and the default is "ISO-8859-1".

Solution:

Add a sentence before PrintWriter out = response.getWriter();

:

response.setHeader("Content-type" , "application/json;charset=UTF-8");

Note: Be sure to add it before PrintWriter out = response.getWriter();, otherwise the charset of PrintWriter will still be the default "ISO-8859-1 "

The above is the detailed content of What should I do if java returns garbled characters?. 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

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 Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools