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!