UTF-8 encoding problem using messages.properties in Spring Boot with Thymeleaf

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

UTF-8 encoding problem using messages.properties in Spring Boot with Thymeleaf

RollerBlade
When I use my Thymeleaf templates without expression including only string literals as pure html code it correctly shows the non ACSII Hungarian letters.

When I put the same string literal to a variable in messages.properties file and referring it as #{something} the expression is not shown properly. Instead of the non-ASCII Hungarian letters I see �r�l�k instead of Örülök.

What can be the problem? My html templates use utf-8 encoding. My thymeleaf encoding is configured by spring boot to use utf-8 by default?
Reply | Threaded
Open this post in threaded view
|

Re: UTF-8 encoding problem using messages.properties in Spring Boot with Thymeleaf

mani
You need to save the file as Encode in UTF-8 without BOM. It works for me.
Steps:
1. Edit the file in notepad++ and have a copy of these content in one more file.
2. Go to menu Encoding and choose Encode in UTF-8 without BOM.
3. If your file shows some char like xE9 etc., then copy original content to your file and save.
4. Close and re-open the file and check the encoding remains same as "Encode in UTF-8 without BOM".
 If encoding default to Encode in AnsII that means you had few chars which are like "xE9" and your file didn't saved as Encode in UTF-8 without BOM.
5. If encode remains "Encode in UTF-8 without BOM".
6. Run your application and you could able to see the translated content.