gdufo

           

          AppFuse中DisplayTag亂碼問題的解決(1.9)

          AppFuse中DisplayTag亂碼問題的解決
          2007-06-11 18:01

          工作環境:Windows Server2003SE,Eclipse3.1.1,MySQL5.0,Tomcat5.5.9,JDK1.5.0_07,Ant1.6.5
          在中文環境下使用AppFuse,會遇到DisplayTag的題頭信息亂碼現象(最新發布的AppFuse1.9.4也有這個問題),如下圖:

          解決方法:
          1.查看web/web-inf/classes目錄下是否存在displaytag_zh_CN.properties配置文件,1.9.1前的版本沒有中文版本的配置文件.如果Eclipse中打開看到的是亂碼,選擇File->Properties 選擇UTF-8類型查看,下同。
          2.打開項目build.xml文件,找到target copy-resources所在位置(通過字符串copy-resources查找快)
          將原來的代碼:
                <target name="copy-resources" depends="prepare"
                    description="Copy .properties and .xml files from source directory">
                    <copy todir="${build.dir}/web/classes" includeEmptyDirs="no">
                        <fileset dir="web/WEB-INF/classes">
                            <exclude name="ApplicationResources_zh*.properties"/>
                            <include name="*.properties"/>
                            <include name="*.xml"/>
                            <include name="*.vm"/>
                        </fileset>
                        <filterset refid="variables.to.replace"/>
                    </copy>
                    <native2ascii src="web/WEB-INF/classes" _fcksavedurl=""web/WEB-INF/classes"" dest="${build.dir}/web/classes"
                        includes="ApplicationResources_zh*.properties" encoding="UTF-8"/>
                    <generate-database-properties/>
                    <copy todir="${build.dir}/web/classes" file="database.properties"/>
                </target>
          修改為(添加紅色的):
                <target name="copy-resources" depends="prepare"
                    description="Copy .properties and .xml files from source directory">
                    <copy todir="${build.dir}/web/classes" includeEmptyDirs="no">
                        <fileset dir="web/WEB-INF/classes">
                            <exclude name="ApplicationResources_zh*.properties"/>
                            <exclude name="displaytag_zh*.properties"/>                
                            <include name="*.properties"/>
                            <include name="*.xml"/>
                            <include name="*.vm"/>
                        </fileset>
                        <filterset refid="variables.to.replace"/>
                    </copy>
                    <native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
                        includes="ApplicationResources_zh*.properties" encoding="UTF-8"/>
                    <native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
                            includes="displaytag_zh*.properties" encoding="UTF-8"/>        
                    <generate-database-properties/>
                    <copy todir="${build.dir}/web/classes" file="database.properties"/>
                </target>
          通過native2ascii將displaytag_zh_CN.properties配置文件同ApplicationResources_zh*.properties一樣轉換下,就OK了。奇怪Matt Raible在最近AppFuse1.9.4中都沒改過來:)

          =====

                 1.build.xml里面display資源沒有國際化處理,也就是沒有進行編碼,在build.xml進行修改使之進行國際化.
                修改方案:
                   <native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
                       includes="ApplicationResources_zh*.properties" encoding="UTF-8"/>
                   <generate-database-properties/>
                改為:
                   <native2ascii src="web/WEB-INF/classes" dest="${build.dir}/web/classes"
                       includes="*_zh*.properties" encoding="UTF-8"/>
                   <generate-database-properties/>

               2.Tomcat 的URLEnCording要設置為UTF8,應為appfuse是以utf-8打包的

               3.就是要對原始ApplicationResources_zh_cn.properties進行ascii編碼轉換然后丟到classes里面,不要用他ant自動轉換過的.奇怪的是appfuse的ant的時候是對文件進行轉換了,但是還是有部分中文存在亂碼,奇怪ing......不知道是appfuse的疏忽還是什么.繼續研究中...我是appfuse-1.9-src的包.但是我手工轉了下ant之前的源碼,發現亂碼問題消失.就這個原因搞了我一個晚上....郁悶
               修改方案:
               native2ascii -encoding UTF-8    ApplicationResources_zh_CN.properties te   (te為轉后文件名)
               native2ascii   te   ApplicationResources_zh_CN.properties1 -reverse(轉回來 呵呵)

               補充一點,在appfuse的appfuse-1.9-src這個包里的 ApplicationResource...直接打開是中文是亂碼,可以采用上面的兩條命令把它還原出來.便于我們的開發然后修改ant任務即可.而對于appfuse-jsf-1.9-src來說,它的applicationResource...打開后就是我們可以看懂的中文:).

          posted on 2008-08-06 23:00 gdufo 閱讀(672) 評論(0)  編輯  收藏 所屬分類: Appfuse

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 南宫市| 鲁甸县| 海宁市| 平武县| 余姚市| 定西市| 黄冈市| 龙川县| 左贡县| 汕头市| 蓬溪县| 宜阳县| 阜城县| 舟曲县| 巧家县| 上饶市| 吴旗县| 浏阳市| 泽普县| 莱州市| 西宁市| 兴隆县| 驻马店市| 九龙城区| 多伦县| 龙川县| 万山特区| 随州市| 巩留县| 西丰县| 仁寿县| 榕江县| 丰都县| 武胜县| 灵川县| 古丈县| 新建县| 原平市| 陵水| 星座| 深水埗区|