简体   繁体   English

Tomcat重新启动或重新部署会破坏Java源文件中的Unicode字符

[英]Tomcat restart or redeploy breaks unicode characters from java source files

I have developed a liferay 6.2 application using jsf and primefaces 4. I have unicode characters both in xhtml files and java source files. 我使用jsf和primefaces 4开发了liferay 6.2应用程序。xhtml文件和java源文件中都有Unicode字符。 There a strange behaviour of breaking my characters after tomcat restart or redeploy of application and the problem is only with characters coming from the source files. 在tomcat重新启动或重新部署应用程序后,有一种奇怪的行为来破坏我的字符,而问题仅在于源文件中的字符。 The rest unicode characters on the page are displayed correctly. 页面上其余的unicode字符正确显示。 And the behaviour is not always reproducible. 并且该行为并不总是可复制的。

I have read posts referring to setting the jvm's or tomcat default encoding and main suggested action was setting -Dfile.encoding=UTF-8 but didn't have any luck. 我读过有关设置jvm或tomcat默认编码的帖子,主要建议的操作是设置-Dfile.encoding = UTF-8,但没有任何运气。 I am using tomcat 7.0.42 我正在使用tomcat 7.0.42

If you are using Eclipse, try setting the text encoding in your project Properties>Resource 如果使用的是Eclipse,请尝试在项目的Properties> Resource中设置文本编码。

在此处输入图片说明

The problem has to do with the encoding of the class files. 问题与类文件的编码有关。 The solution was to set the correct encoding for javac. 解决的办法是为javac设置正确的编码。 I finally discovered that in eclipse I had to edit the build. 我终于发现在Eclipse中我必须编辑构建。 user .properties file to set javac.encoding = UTF-8 用户 .properties文件来设置javac.encoding = UTF-8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM