Spring Boot internationalization works for French but not Korean

388 views Asked by At

I have messages_ko.properties file and I set my browser to Korean. It loads up the page using the message file but the internationalized text is all question marks.

????? ...

It looks like Korean in the Eclipse editor. The file editor is set to UTF-8. My Google Chrome is able to display Korean. This whole page http://www.hyundaigroup.com/ is in Korean. I used

curl -H "Accept-Language: ko" localhost:8080/page 

And the internationalized text is mostly question marks still. I opened the messages_ko.properties file in Notepad++ and it shows Korean and that it's encoded in UTF-8.

It works fine when I set my browser to French. Non-English characters (Intéressé) show up fine. The HTML is marked as UTF-8.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

So why is Spring Boot mangling the Korean characters but not the French?

I'm using an AcceptHeaderLocaleResolver.

@Bean
public LocaleResolver localeResolver() {
    AcceptHeaderLocaleResolver ahlr = new AcceptHeaderLocaleResolver();
    ahlr.setDefaultLocale(Locale.ENGLISH);
    return ahlr;
}

And I'm using Spring Messages and JSP to print the internationalized text.

<spring:message code="title"/>
1

There are 1 answers

0
Chloe On BEST ANSWER

I saw the server response header was

Content-Type: text/html;charset=ISO-8859-1

I added

<%@ page contentType="text/html;charset=UTF-8" %>

To the top of the page and then it worked.