2
votes

I can't make UTF-8 work in Tomcat. I've already done the following configurations:

  1. Set URIEncoding="UTF-8" on my server.xml
  2. export CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF-8" in catalina.bat
  3. Configured Spring CharacterEncodingFilter
  4. Set UTF-8 in all html files
  5. Maven sourceEncoding build UTF-8

When I call my webapp url in the browser or postman I can see Content-Type →text/html;charset=UTF-8. But the page is rendered with wrong encoding. And when I open the deployed webapp in Tomcat folder the html files are with the correct encoding too. I really don't know what to do.

I am using Angular, Spring, Jersey, Spring Security and Tomcat.

Thanks.

1
How do you know that the page is rendered with the wrong encoding? What do you see on your screen that makes you say that that is the case? - Jesper
Because I want this "EMPÓRIO" and returns this "EMPÓRIO" - brazuka
Character encoding errors can be hard because the error might be anywhere in the chain. Where does this text come from? Is it read from its source with the correct encoding? Is it written to the webpage with the correct encoding? Does anything happen in between where the encoding might be messed up? - Jesper
This text cames from an html file. Yes, it is read from its source with the correct encoding. No, it is not written with the correct encoding. - brazuka
As Jesper pointed out you have to search through the whole chain to detect the error. How do you read/write the html files? One guess: InputStreamReader and OutputStreamWriter uses the default encoding if no other parameter is given. You need to set UTF-8 there as well. - rics

1 Answers

0
votes

בס"ד

In servlet data response?? you can try:

response.setCharcterEncoding(("utf-8"));

Good luck.