问题
In struts application.properties we have key and value pairs. We use this file to display static text on html/jsp pages in browser.
But when I entered German characters from : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_script_charset
entered this text : αβγδεζηθ (Greek Symbols)
at some button in html page, it shows some different characters:
Note : i have used file encoding as UTF-8 in this case, and then compile the code.
What should i do to support these characters also. Please give some links so that it would be helpful.
Thanks....
回答1:
Some characters cannot be stored AS IS on the properties file, it will have to entered using Unicode escape characters:
The default encoding for property files is ISO-8859-1
also known as Latin-1
characters. All non-Latin-1 characters must then be entered using Unicode escape characters.
Example, consider the following example using a french sentence:
#property file example:
sentence.french=Son père est allé à l'hôtel.
There are certain accents that are not part of the Latin-1 character set. Therefore, escaping it to its Unicode escape characters, we get:
#property file example:
sentence.french=Son p\u00e8re est all\u00e9 \u00e0 h\u00f4tel.
- Source.
I hope this helps.
来源:https://stackoverflow.com/questions/23650255/struts-application-properties-file-is-not-supporting-accented-characters