Struts中文問(wèn)題怎么解決_第1頁(yè)
Struts中文問(wèn)題怎么解決_第2頁(yè)
Struts中文問(wèn)題怎么解決_第3頁(yè)
Struts中文問(wèn)題怎么解決_第4頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Struts中文問(wèn)題怎么解決Struts中文問(wèn)題怎么解決碰到struts中文問(wèn)題時(shí),JSP頁(yè)面上仍然顯示的是亂碼,下面 方法在windows的weblogicS下,和Unix的weblogicS下均正確顯 示漢字。一起來(lái)看看吧!以下是代碼內(nèi)容:首先是JSP頁(yè)而的內(nèi)容,最簡(jiǎn)化的一個(gè)formTestltemEnglish:TestltemChinese:注意,頁(yè)而的字符集一定要定義成gb2312,否則顯示不了正確 的漢字了,代碼上半部的logic: iterate標(biāo)簽是action處理完畢 后,返回給頁(yè)而顯示的。至于form提交的部分,由struts機(jī)制去 做了,我只把testitem_confi

2、g這個(gè)action的原代碼給出,大家就 看明白了:publicclassTestltemConf igAct ionextendsActionpub1icAct i onForwardexecute(ActionMappingmapping, Ac t i onF ormf orm,HttpServletRequestrequest,HttpServletResponseresponse)throwsExceptionTestltemConfigFormpcForm=(TestltemConfigForm)form;StringentryIndexArray=pcForm. getEntryp

3、ro();StringtestPartKey;ArrayListtestPartOpt i onsEn=newArrayL i s t();ArrayListtestPartOptionsCn=newAr:rayList ();ServletContextcontext=getServlet()o getServletContext();Stringfile二context. getRealPath( /WEB- INF/classes/resource/TestItem. properties M ;PropertiesFileOperatepOperate=newPropertiesFil

4、eOperate (f ile);Propertiesproperty=pOperate getProperties ();inttestpartnum=Integer parseint(property. getProperty( “t est. item num);if(pcForm. getOperateFlag()!=null&!”。 equals(pcForm. getOperateFlag()if(Integer. parseint(pcForm. getOperateFlag()=1&pcForm. getTestltemEn () !=null&!”。equals(pcForm

5、. getTestltemEn()StringaddKeyEn= utest item. en. ” + (testpartnum+1);StringaddKeyCn= “test item. cn. ” +(testpartnum+1);StringaddValueEn=pcForm. getTestitemEn()。trim();StringaddValueCn=pcForm. getTestltemCnO。trim();StringaddValueCnWirite=newString(addValueCn. getBytes( “I so-8859-1” );pOperatemodify

6、Properties( “test .item, num,(testpartnum+l)+;pOperate. addProperties(addKeyEn, addValueEn);pOperate. addProperties(addKeyCn, addValueCnWirite);pOperate. saveFile ();pOperate二null;if(Integer parselnt(pcForm getOperateFlag()=2&pcForm. getTestltemEn()!=null&! “”。equals(pcForm. getTestitemEn()intentryl

7、ndex=lnteger parselnt(pcForm getTestltemlndex()。 trimO);StringaddKeyEn= utest item. en. ” +entryIndex;StringaddKeyCn= “test item cn. ” +entrylndex;StringaddValueEn=pcForm. getTestitemEn()。trim();StringaddValueCn=pcForm. getTestltemCnO。trim();StringaddValueCnWirite=newString(addValueCn. getBytes( “I

8、so-8859-1” );pOperate. modifyProperties(addKeyEn, addValueEn);pOperate modifyProperties(addKeyCn, addValueCnWirite);pOperate saveFile();pOperate=null;if (Integerparselnt (pcForm getOperateFlag() =3) for(inti=0;ientrylndexArray. length;i+) StringindexEntry=(entryIndexArrayio substring (1, entrylndexA

9、rrayio indexOf( ,)o trim();StringaddKeyEn= utest item en. ” +indexEntry;StringaddKeyCn= utest item. cn. ” +indexEntry;pOperate modifyProperties(addKeyEn;pOperate. modifyProperties(addKeyCn, ” );pOperate. saveFile();pOperate=null;PropertiesFileOperatepOperateShownewPropertiesFileOpera te (file);Prope

10、rt iespropertyShowpOperat eShow. getProperties();inttestpartumbe:r=Integer parselnt(propertyShow getPrope rty( “test item num);ArrayListarray二newArrayList();for(inti=l;i二testpartNumber;i+)ArrayListdrr=newArgyList();testPartKey= “test.item. en. ” +i;if(propertyShow getProperty(testPartKey)!=null&! o

11、equals(propertyShow.getProperty(testPartKey)arr. add (i+ ” );testPartOptionsEn. add(propertyShow. getProperty(testPartK ey);arr add(propertyShow getProperty(testPartKey);testPartKey= test item. cn. +i;testPartOptionsCn. add (newString(propertyShow getProperty (testPartKey) o getBytesO, “gb2312”);arr

12、. add(propertyShow. getProperty(testPartKey);array, add (arr);request. setAtt:ribute( “box , array);pcForm. reset(mapping, request);returnmapping. findForward( utestitemone n ;這個(gè)action并不復(fù)雜,首先它定義了一個(gè)properties文件 Testitem, properties,在 web 服務(wù)器下的/WEB- INF/classes/resource/下面,用來(lái)記錄頁(yè)面上輸入的內(nèi)容,由于 StringaddValueCnWirite二newStting(addValueCn. getBytes( ISO- 8859-1”)這個(gè)語(yǔ)句進(jìn)行了字符轉(zhuǎn)換,所以properties文件中記錄 的內(nèi)容大概都是這樣子的:test. item. cn. 29=u7FlDu9699u5F02u5E38如果把程序改成記錄到數(shù)據(jù)庫(kù)中,也應(yīng)該是這個(gè)

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論