I18n: Umlaut not displaying correctly in JSP

I have a JSP that needs to display some German text from some .properties files using fmt: message, for example.

The corresponding entry in the .properties file is: service.test.hware.test = Hardware prüfen (umlaut between r and f in the second word).

In Internet Explorer, this appears as:

Prüfen equipment

umlaut is damaged. Any ideas on what's going on here? Please note that we are using Spring MVC.

+3
source share
3 answers

ü UTF-8 ü, ISO-8859-1 UTF-8. :

System.out.println(new String("ü".getBytes("UTF-8"), "ISO-8859-1")); // ü

, JSP, JSP, , JSP UTF-8 .

HTTP Content-Type. HTTP, . Firebug.

alt text

charset=utf-8.

JSP JSP :

<%@ page pageEncoding="UTF-8" %>

. :

+6

Spring messageSource org.springframework.context.support.ResourceBundleMessageSource, iso-8859-1 , utf-8 (Java iso-8859-1 encoding).

org.springframework.context.support.ReloadableResourceBundleMessageSource. messageSource . . Javadoc / .

:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:message"/>
    <property name="defaultEncoding" value="UTF-8" />
</bean>
+4

, . , ,

  • & uuml; . , -ASCII- {form, 1234 - , /
  • , . UTF-8, .

Or it may be a problem with the encoding used to read the properties file. If you use FileReader, do not do this. Instead, use new InputStreamReader(new FileInputStream(...), encoding)where encodingis the property file encoding.

0
source

Source: https://habr.com/ru/post/1767059/


All Articles