Accented writing and other languages such as Mandarin and Arabic are complex.
I think you have not seen the last of these questions.
You must make sure that you correctly encode the text in any link in the chain.
eg.
- database -> java -> response-> browser
- properties file -> jav-> response-> browser
- request (param / form) → response-> browser
- java → logger-> console
I suggest following this wonderful answer. How to get UTF-8 to work in Java Webapps?
To configure it for spring, use spring s CharacterEncodingFilter.
<filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter>
If you are using i18n, be sure to define the default encoding for your ResourceBundleMessageSource, for example.
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" > <property name="basename" value="classpath:messages"/> <property name="defaultEncoding" value="UTF-8"/> <property name="useCodeAsDefaultMessage" value="false"/> </bean>
Make sure your property files are encoded correctly using Javas native2ascii.
Or better if you use eclipse, I recommend the property editor plugin.
Once upon a time, a third-party structure breaks something and you need to do the “magic”
new String(yourstring, "UTF8")
For more information see here .
Please note that some viewers also need to define an encoding.
Haim raman
source share