Property files conform to the specification using ISO-8859-1.
... the input / output stream is encoded with ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode screens, as defined in Section 3.3 of the Java ™ Language Specification; Only one u character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings.
Thus, any character that does not extend to the ISO-8859-1 range must be escaped in the Unicode escape sequence \uXXXX . You can use the native2ascii tool provided by the JDK to convert them. You can find it in the JDK /bin .
Here's an example assuming that foo_utf8.properties is the one you saved using UTF-8, and that foo.properties is the one you want to use in your application:
native2ascii –encoding UTF-8 foo_utf8.properties foo.properties
In your specific case, the corresponding property will then be converted to:
login = \u041B\u043E\u0433\u0438\u043D
This can then be successfully read and displayed on the JSP page with a minimal @page configuration:
<%@ page pageEncoding="UTF-8" %>
(the remainder that you had does not matter, since the default values are already set above)
If you are using a Java-compatible IDE such as Eclipse, you can simply use the built-in property file editor, which should automatically be associated with .properties files in the project with a Java face. If you use this editor instead of a regular text editor / source editor, it will automatically exit characters that are not covered by the ISO-8859-1 range.
See also:
source share