我使用Struts2,有一个i18n的要求,我已经创建了全局& global_ar属性文件,为英文所有的字符都显示正常,以前我转换所有阿拉伯文本到UTF8代码的时间应用程序运行良好,但当我改变它为纯阿拉伯文本它停止工作,在浏览器中的阿拉伯文本它显示了一些奇怪的字符。
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>发布于 2013-06-20 22:01:38
使用native2ascii将字符集转换为ASCII码。这是消息资源所需的编码。
假设resources是src文件夹下的第一个目录,其中包含您需要转换的消息属性文件。使用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支持的一些字符编码。
https://stackoverflow.com/questions/17207698
复制相似问题