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.
ü 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.
Content-Type
charset=utf-8.
charset=utf-8
JSP JSP :
<%@ page pageEncoding="UTF-8" %>
Spring messageSource org.springframework.context.support.ResourceBundleMessageSource, iso-8859-1 , utf-8 (Java iso-8859-1 encoding).
messageSource
org.springframework.context.support.ResourceBundleMessageSource
iso-8859-1
utf-8
org.springframework.context.support.ReloadableResourceBundleMessageSource. messageSource . . Javadoc / .
org.springframework.context.support.ReloadableResourceBundleMessageSource
:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basename" value="classpath:message"/> <property name="defaultEncoding" value="UTF-8" /> </bean>
, . , ,
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.
FileReader
new InputStreamReader(new FileInputStream(...), encoding)
encoding
Source: https://habr.com/ru/post/1767059/More articles:A method to select an object data source that returns nothing when the code is called - asp.nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1767055/applying-compiler-options-to-specific-files&usg=ALkJrhgxA11WjcHPfpNaLU18pJZHIGyoWwWhat happens when I update the SQL column myself? -Or-simplified conditional updates? - sqlstring search for an array of string fragments - powershellhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1767058/facebook-graph-api-question-how-can-i-get-permanent-permissionaccess-token-to-display-a-public-photo-album-on-a-webpage&usg=ALkJrhhSS0qtwAMPjxYlhCAPgE4PVNv0hwASP.NET: Localization: get .resx value in MVC view using dynamic key - c #Trying to filter XML using XPath - c #What is the safe way to call Debug.Assert from the C ++ CLI? - asserthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1767063/not-enough-variables-to-fit-a-sentinel&usg=ALkJrhhOrLD9XiR441vgkWCZecRxk8fI1AReading from StreamReader in batches - c #All Articles