gdufo

           

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

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

          工作環(huán)境:Windows Server2003SE,Eclipse3.1.1,MySQL5.0,Tomcat5.5.9,JDK1.5.0_07,Ant1.6.5
          在中文環(huán)境下使用AppFuse,會遇到DisplayTag的題頭信息亂碼現(xiàn)象(最新發(fā)布的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一樣轉(zhuǎn)換下,就OK了。奇怪Matt Raible在最近AppFuse1.9.4中都沒改過來:)

          =====

                 1.build.xml里面display資源沒有國際化處理,也就是沒有進(jìn)行編碼,在build.xml進(jìn)行修改使之進(jìn)行國際化.
                修改方案:
                   <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要設(shè)置為UTF8,應(yīng)為appfuse是以utf-8打包的

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

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

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

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 武定县| 平乐县| 准格尔旗| 吉木萨尔县| 泾阳县| 保山市| 冀州市| 宁陵县| 黔东| 平定县| 信阳市| 宜章县| 博乐市| 北碚区| 霍城县| 定边县| 茶陵县| 牡丹江市| 灌云县| 吉林省| 湖州市| 民勤县| 海原县| 奉节县| 奉化市| 喜德县| 铜陵市| 云安县| 武乡县| 九江市| 康马县| 香港 | 金昌市| 龙游县| 晴隆县| 巍山| 永吉县| 平阳县| 栖霞市| 万宁市| 江源县|