1

我正在使用 Struts 2,需要 i18n,我创建了 global & global_ar 属性文件,对于英语,所有字符都正确显示,之前我将所有阿拉伯文本转换为 UTF-8 代码,时间应用程序运行良好,但是当我将其更改为纯阿拉伯文本时,它停止工作,在阿拉伯文本浏览器中显示一些奇怪的字符。

JSP 文件

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%> 
<%@ taglib prefix="t" tagdir="/WEB-INF/tags/custom_tag"%> 
<t:template> 
   <s:form action="visitations.action" id="visitationForm" theme="simple" method="post">  </s:form>     
<s:text name="country" />:<span class="required">*</span>
</t:template>
4

1 回答 1

0

用于native2ascii将字符集转换为 ASCII。这是消息资源所需的编码。

假设resourcessrc文件夹下的第一个目录,其中包含您需要转换的消息属性文件。使用ant

<target name="native2ascii">
  <delete dir="${classes.dir}/resources" includes="*.properties" />
  <native2ascii encoding="cp1256" src="${source.dir}/resources" dest="${classes.dir}/resources" includes="*.properties" />
  <copy todir="${exploaded.dir}/WEB-INF/classes/resources">
    <fileset dir="${classes.dir}/resources" includes="*.properties" />
  </copy>
</target>

在每个构建上运行此脚本,您可能应该自定义它以正确翻译它,选择文件本机编码的编码字符集。

您可以找到一些 JVM 支持的字符编码:Character Encoding

于 2013-06-20T14:01:38.497 回答