我正在一个支持两种语言Struts-1EnglishTurkies项目。要显示消息,我们使用InternationalizationStruts-1功能,因此我们有两个属性文件(ApplicationResources_en.propertiesApplicationResources_en.propertie s)来存储需要显示给用户的消息。

对于英文版ApplicationResources_en.properties键,值是

farequoteautomatic.entry-area.gen.emd.fareamount=Fare Amount


对于Turkies版本ApplicationResources_tr.properties键,值是

farequoteautomatic.entry-area.gen.emd.fareamount=Ücret Miktarı


Locale为英语时,一切工作正常,这意味着当我们使用英语版本时。该键Fare Amount正确且预期输出。

但是,当更改Locale时,意味着当我们尝试使用turkey版本时,没有正确的输出。它显示特殊字符,而不是写在属性文件中的实际字符。

在属性文件中,消息为Ücret Miktarı,但在浏览器中输出的消息为�cret Miktar�

注意:我已经检查了我的Firefox浏览器是否默认设置为Unicede (UTF-8)编码,并且在每个页面中都包含一个header.jsp,在每个页面中我们都有一个像<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />这样的META标签。

我不明白我在做什么错。请帮我。

最佳答案

检查您的浏览器编码并将其设置为UTF-8

尝试这个
在web.xml中

<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>bt.gov.g2c.framework.common.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>

09-10 02:20
查看更多