I am trying to display chines characters but its showing ??????????. In my spring-servlet I have
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
and in my massages.property I have added some chines characters like this
這對中國的考驗
First line of my .jsp file I have
<%@ page pageEncoding="UTF-8" %>
If I encode the chines in ascii format then its working fine. but I don’t want to do that. Is there anything I am missing.
Please help.
As per their documentation, the properties files are by default read using ISO-8859-1 encoding. You’d need to use unicode escapes like as in
\uXXXXfor each character beyond the supported range of ISO-8859-1. JDK offers thenative2asciitool for this in the/binfolder. You should then use the converted properties file instead.E.g. (in command console)
Where
some.properties.utf8is the properties file which you saved in UTF-8 andsome.propertiesis the converted properties file which you should instead use in your web application.The
would then become
Most IDEs like Eclipse, IntelliJ and maybe also Netbeans (not sure as I’ve never used it) will automatically do this when you use the builtin properties file editor.