简体   繁体   English

java / Servlets / ISO-8859-1而不是UTF-8

[英]java / Servlets / ISO-8859-1 instead of UTF-8

I have set character encoding of the response to UTF-8 by 我已经设置了响应UTF-8字符编码

response.setCharacterEncoding("UTF-8");

Despite that, on the client-side, several characters are broken. 尽管如此,在客户端,几个字符还是坏了。 I had a look at the response's header in the browser tool, and i found out that the encoding was set to ISO-8859-1 . 我在浏览器工具中查看了响应的标题,发现编码设置为ISO-8859-1

How can i solve this issue? 我该如何解决这个问题? What is the underlying problem? 潜在的问题是什么?

I have found the problem: 我发现了问题:

response.setCharacterEncoding("UTF-8"); must be declared before response.getWriter(); 必须 response.getWriter(); 之前声明response.getWriter();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM