Omer-Pitou
asked on
Spring Charset Encoding failing to handle special characters
Hello Sirs
I am using serious issues with Charset Encoding in a REST application. I use Spring and the encoding in the bean MessageSource and Tymeleaf resolver is set to UTF-8.
I get this when I return Json string:
\ufffd replacing special characters like é, or any other letter with accent.
How can I solve this?
Best regards.
I am using serious issues with Charset Encoding in a REST application. I use Spring and the encoding in the bean MessageSource and Tymeleaf resolver is set to UTF-8.
I get this when I return Json string:
\ufffd replacing special characters like é, or any other letter with accent.
How can I solve this?
Best regards.
ASKER
Hello Bugada,
It doesn't work. Still having the same issue.
It doesn't work. Still having the same issue.
Can you show us the controller that returns the JSON string?
Silly question, your message bundle has been saved in utf8?
ASKER
I found the solution
I changed MessageSource default encoding from UTF-8 to ISO-8859-1.
@Bean(name="messageSource" )
public MessageSource messageSource() {
ReloadableResourceBundleMe ssageSourc e resource = new ReloadableResourceBundleMe ssageSourc e();
resource.setBasename("clas spath:mess ages");
resource.setDefaultEncodin g("ISO-885 9-1"); //1 UTF-8
return resource;
}
I changed MessageSource default encoding from UTF-8 to ISO-8859-1.
@Bean(name="messageSource"
public MessageSource messageSource() {
ReloadableResourceBundleMe
resource.setBasename("clas
resource.setDefaultEncodin
return resource;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That's because the bundle message isn't saved in utf8 but in iso8859
Open in new window
or use produces property in your request mappings if you are in a @RestController
Open in new window