且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在春季MVC中不渲染汉字

更新时间:2023-01-30 21:38:37

根据其文档,属性文件是默认情况下使用ISO-8859-1编码读取。您需要对\uXXXX 这样的Unicode转义IEC_8859-1#Codepage_layout rel = nofollow> ISO-8859-1的支持范围。 JDK在 / bin 文件夹中为此提供了 native2ascii 工具。然后,您应该使用转换后的属性文件。

As per their documentation, the properties files are by default read using ISO-8859-1 encoding. You'd need to use unicode escapes like as in \uXXXX for each character beyond the supported range of ISO-8859-1. JDK offers the native2ascii tool for this in the /bin folder. You should then use the converted properties file instead.

例如。 (在命令控制台中)

E.g. (in command console)

native2ascii -encoding UTF-8 some.properties.utf8 some.properties

其中 some.properties.utf8 是保存在UTF中的属性文件-8和 some.properties 是转换后的属性文件,应在Web应用程序中使用。

Where some.properties.utf8 is the properties file which you saved in UTF-8 and some.properties is the converted properties file which you should instead use in your web application.

some.key = 這對中國的考驗

然后将成为

some.key = \u9019\u5c0d\u4e2d\u570b\u7684\u8003\u9a57

大多数IDE,例如Eclipse,IntelliJ和也许当您使用内置属性文件编辑器时,Netbeans(不确定,我从未使用过)也会自动执行此操作。

Most IDEs like Eclipse, IntelliJ and maybe also Netbeans (not sure as I've never used it) will automatically do this when you use the builtin properties file editor.