在appfuse中设置好ApplicationResource_zh*.properties相关内容以后,新增加的内容中文显示就没有问题了,但是表格上方和下方的文字还是乱码,经查是displaytag没有设置中文的问题。可以说是appfuse编译过程的错误吧。
现有的appfuse编译,有如下这一段:
<target name="copy-resources" depends="prepare"></target> description="Copy .properties and .xml files from source directory">
<copy todir="${build.dir}/web/classes" includeemptydirs="no"></copy>
<fileset></fileset>
<exclude name="ApplicationResources_zh*.properties"></exclude>
<exclude name="ApplicationResources_de.properties"></exclude>
<exclude name="ApplicationResources_fr.properties"></exclude>
<exclude name="ApplicationResources_nl.properties"></exclude>
<exclude name="ApplicationResources_pt*.properties"></exclude>
<include name="*.properties"></include>
<include name="*.xml"></include>
<include name="*.vm"></include>
<filterset refid="variables.to.replace"></filterset>
<native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"></native2ascii> includes="ApplicationResources_zh*.properties" encoding="UTF-8"/>
可以看到,对于ApplicationResources_zh*.properties文件没有直接拷贝,而是通过native2ascii进行了转换,这样的内容就不会产生乱码。而displaytag_zh*.properties直接被拷贝过去,还是utf-8格式,因此页面显示是乱码。
修改方法如下:
<target name="copy-resources" depends="prepare"></target> <target name="copy-resources" depends="prepare"></target> description="Copy .properties and .xml files from source directory">
<copy todir="${build.dir}/web/classes" includeemptydirs="no"></copy>
<fileset></fileset>
<exclude name="ApplicationResources_zh*.properties"></exclude>
<exclude name="ApplicationResources_de.properties"></exclude>
<exclude name="ApplicationResources_fr.properties"></exclude>
<exclude name="ApplicationResources_nl.properties"></exclude>
<exclude name="ApplicationResources_pt*.properties"></exclude>
<exclude name="displaytag_zh*.properties"></exclude>
<include name="*.properties"></include>
<include name="*.xml"></include>
<include name="*.vm"></include>
<filterset refid="variables.to.replace"></filterset>
<native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"></native2ascii> includes="*_zh*.properties" encoding="UTF-8"/>