Home>Article>Java> How to deal with garbled code in Java background

How to deal with garbled code in Java background

藏色散人
藏色散人 Original
2020-04-11 10:00:14 2115browse

How to deal with garbled code in Java background

What should I do if the java background is garbled?

Solution to Chinese garbled code in java background

//将乱码字符串按照错误的编码方式转换为原始的字符串序列 byte[] bs = 乱码字段.getBytes("ISO8859-1"); //将原始的字符串序列按照正确的编码转换为正确的文字即可 新字段 = new String(bs,"UTF-8");

The second is that spring provides an encoding filter and just add the following code to web.xml

Recommended tutorial: "java learning"

  字符集过滤器 encodingFilter org.springframework.web.filter.CharacterEncodingFilter  字符集编码 encoding UTF-8     encodingFilter /* 

The above is the detailed content of How to deal with garbled code in Java background. 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