锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久国产精品亚洲一区,亚洲激情视频图片,91亚洲国产成人精品下载http://m.tkk7.com/juhongtao/category/6224.htmlzh-cnFri, 02 Mar 2007 03:30:21 GMTFri, 02 Mar 2007 03:30:21 GMT60鍦⊿truts涓嬌鐢↗avaBean鍜孡ist錛堝琛屾暟鎹級綾誨瀷灞炴?/title><link>http://m.tkk7.com/juhongtao/archive/2006/12/14/87619.html</link><dc:creator>javaGrowing</dc:creator><author>javaGrowing</author><pubDate>Thu, 14 Dec 2006 01:28:00 GMT</pubDate><guid>http://m.tkk7.com/juhongtao/archive/2006/12/14/87619.html</guid><wfw:comment>http://m.tkk7.com/juhongtao/comments/87619.html</wfw:comment><comments>http://m.tkk7.com/juhongtao/archive/2006/12/14/87619.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/juhongtao/comments/commentRss/87619.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/juhongtao/services/trackbacks/87619.html</trackback:ping><description><![CDATA[聽鍦?Strust 涓紝鎴戜滑鍙兘緇忓父瑕佸湪 ActionForm 涓嬌鐢ㄥ叾浠?JavaBean 浣滀負灞炴х被鍨嬶紝榪欓噷灝卞瓨鍦ㄧ潃濡備綍浣跨敤濂借繖浜涘睘鎬т笌 HTML Form 涔嬮棿鐨勬暟鎹氦鎹紝涓嬮潰鎴戜滑灝辮繖浜涢棶棰樺仛涓璁茶В銆?br /><br />濡傚湪鐢ㄦ埛娉ㄥ唽鐣岄潰涓紝鎴戜滑閫氬父浼氬皢鐢ㄦ埛鐨勮仈緋繪柟寮忓艦鎴愪竴涓崟鐙殑鏂扮殑 Class 錛屽 Contact 錛屽寘鍚互涓嬪睘鎬э細鐢佃瘽 (tel) 錛屾墜鏈?cell) 錛?Email(email) 錛?QQ(qq) 錛岄氫俊鍦板潃 (adress) 絳夌瓑錛岃繖鏍鋒潯鐞嗕篃姣旇緝娓呮櫚錛屼互涓嬫槸榪欎釜ActionForm 鐨勯儴鍒嗕唬鐮侊細<br /><br />public class RegisterForm extends ActionForm<br /><br />{<br /><br />private Integer id;<br /><br />private String logonName;<br /><br />private String realName;<br /><br />private Contact contact=new Contact();<br /><br />鈥︹︹?.<br /><br />}<br /><br />鍦ㄨ繖閲屾垜浠渶瑕佸皢 Contact 瀹炰緥鍖栵紙鍦?reset 鍑芥暟涓渶瑕侀噸鏂板疄渚嬪寲錛夛紝榪欎富瑕佸洜涓?Struts 鐨勬満鍒訛細濡傛垜浠皢 HTML 鐨凢orm 鍏冪礌錛堝 email 錛夊間紶緇?ActionForm 錛?Struts 闇瑕佹墽琛岀殑鎿嶄綔鏄痝etContact().setEmail(String email) 錛屽鏋滆繖鏃惰繑鍥炵殑 contact 瀵硅薄涓虹┖鐨勮瘽錛岄偅涔堣祴鍊煎浣曡繘琛岋紝鑰屼笖Struts 涔熶笉浼氱煡閬撳浣曞幓瀹炰緥鍖?Contact 錛屾湁鏃惰繖浜?JavaBean 鐨勭被鍨嬫湁鍙兘鏄帴鍙o紝瀹炰緥鍖栨洿鏄湭鐭ワ紝鎵浠ュ叧浜嶫avaBean 綾誨瀷鍦?ActionForm 涓殑瀹炰緥鍖栵紝浣犻渶瑕佽嚜琛屽畬鎴愶紝鑰屼笖蹇呴』瀹屾垚銆傝嚦浜庡湪瀹為檯鎿嶄綔涓垽鏂?JavaBean鏄惁琚繘琛岃繃鐩稿叧鎿嶄綔錛堜笉鍐嶆槸鍒濆鐘舵侊級錛屼綘闇瑕佽嚜琛屽垽鏂紝鍏跺疄涔熷緢綆鍗曪紝濡傚彲鍦?Contact 綾諱腑緙栧啓涓涓嚱鏁版楠屼竴涓嬪嵆鍙?br /><br />ActionForm 鍒涘緩瀹屾瘯鍚庯紝鎴戜滑闇瑕佸湪 Jsp Form 涓紩鐢ㄨ繖浜?JavaBean 綾誨瀷鐨勫睘鎬у鹼紝閭e氨寰堢畝鍗曞暒錛屽彧闇閲囩敤鈥?Form 鐨勫睘鎬у悕縐扳濓紜鈥?. 鈥濓紜鈥?JavaBean 涓殑灞炴у悕縐扳濈粨鏋勬瀯鎴愮殑鍚嶇О浠樼粰鐩稿叧鍏冪礌鍗沖彲銆傚錛?br /><br /><html:text property="contact.email"><br /><br />閫氳繃榪欑鏂瑰紡鎴戜滑灝卞彲浠ュ鐞嗗ソ ActionForm 涓殑 JavaBean 綾誨瀷鐨勫睘鎬у間簡銆?br /><br />瀹為檯鐨勬儏鍐靛彲鑳芥洿澶嶆潅浜涳紝鎴戜滑鏈夋椂鍙兘瑕佹彁浜ゅ琛屾暟鎹埌鍚庨錛岃屼笖琛屽唴鐨勬暟鎹槸鐩稿叧鐨勶紝濡傛垜浠渶瑕佹彁浜ゅ涓敤鎴風殑鑱旂郴鏂瑰紡錛岃繖浜涜鍐呯殑鏁版嵁錛屽email 錛岀數璇濓紝鎵嬫満錛岃繖浜涙暟鎹兘鏄拰鐢ㄦ埛緙栫爜鐩稿叧鐨勶紝鐜板湪鎴戜滑淇敼涓涓?Contact 綾伙紝娣誨姞涓涓敤鎴風紪鐮?(userId)灞炴э紝榪欐椂鎴戜滑鏋勫緩鐨?ActionForm 涓彲鑳介渶瑕佷竴涓垪琛ㄦ暟鎹紙 List 錛夌被鍨嬫潵澶勭悊榪欑鎯呭喌銆備互涓嬫槸榪欎釜 ActionForm鐨勯儴鍒嗕唬鐮侊細<br /><br />public class ModifyBatchContactForm extends ActionForm<br /><br />{<br /><br />private List contact =new AutoArrayList (Contact.class);<br /><br />鈥?.<br /><br />}<br /><br />鍦ㄤ互涓婁唬鐮佷腑錛屾垜浠悓鏍峰鐞嗕簡 List 綾誨瀷鏁版嵁鐨勫垵濮嬪寲銆?Struts 鍦ㄧ粰 List 涓殑瀵硅薄璧嬪兼椂錛屽綋鐒墮渶瑕佸厛鑾峰彇 List鏁版嵁錛岀劧鍚庡湪鑾峰彇 List 涓煇涓涓璞★紙閫氳繃 Index錛夛紝鏈鍚庣粰瀵硅薄璧嬪箋傚湪榪欓噷鎯蟲垜浠彲浠ユ洿璇︾粏鐐瑰垎鏋愭祻瑙堝櫒绔紶榪囨潵鏁版嵁錛屽瓧孌靛煎艦寮忓涓嬶細contact[0].email= linux_china@hotmail.com 錛?Struts 鑾峰彇 ActionForm 涓殑 List鏁版嵁鍚庯紝閫氳繃 Index 錛堟鏃朵負 0 錛夋潵鑾峰彇 List 涓皝瑁呯殑 JavaBean 瀵硅薄錛岀劧鑰屾鏃?List鏄┖鐨勶紙灝界鍒濆鍖栦簡錛屼絾鏄病鏈夋暟鎹級錛屾槸鏃犳硶鍙栧緱灝佽鐨勫璞$殑錛屽洜姝ゆ垜浠鍦?Struts 鑾峰彇 List涓皝瑁呯殑瀵硅薄鐨勬椂鍊欑粰瀹冨垱寤轟竴涓紝榪欐牱灝變繚璇佸璞$殑鑾峰彇鍜岃祴鍊肩殑鎴愬姛榪涜錛屾墍鏈夋垜浠柊寤轟竴涓?AutoArrayList 綾伙紝緇ф壙ArrayList 錛屽彧瑕侀噸鍐?get(int index) 鏂規硶鍗沖彲錛屽叾瀹炲緢綆鍗曪紝浠g爜濡備笅錛?br /><br />public class AutoArrayList extends ArrayList {<br /><br />private Class itemClass;<br /><br />public AutoArrayList(Class itemClass) {<br /><br />this.itemClass = itemClass;<br /><br />}<br /><br />public Object get(int index) {<br /><br />try {<br /><br />while (index &gt;= size()) {<br /><br />add( itemClass.newInstance());<br /><br />}<br /><br />} catch (Exception e) {<br /><br />e.printStackTrace();<br /><br />}<br /><br />return super.get(index);<br /><br />}<br /><br />}<br /><br />榪欐牱鎴戜滑灝卞畬鎴愬彲浠ュ琛屾暟鎹彁浜ょ殑 ActionForm璁捐錛岃繖閲岃繕鏈夌偣鎻愰啋錛屽鏋滀粠嫻忚鍣ㄧ浼犺繃鏉ョ殑琛岀儲寮曟槸璺寵穬鏄殑錛屽緙哄皯涓棿琛岋紝鑰屼綘涓嶆兂瑕佽繖浜涙暟鎹殑璇濓紝涓旈灝捐 index鐩稿樊寰堝ぇ鐨勮瘽錛岃繖縐嶆柟寮忓彲鑳戒笉澶傚悎銆傝繖縐嶅琛屾彁浜ゅ艦寮忔瘮杈冮傚悎瀵瑰浐瀹氳鐨勬暟鎹鐞嗐傚鏋滆鏁頒笉鍥哄畾鐨勮瘽錛屼綘鍙互鍙傝冧嬌鐢?MapForm 鏂瑰紡瀹炵幇銆?br /><br />涓嬮潰鎴戜滑灝辯湅鐪嬪浣曞湪 Jsp 涓嬌鐢ㄨ繖涓?ActionForm 錛屽叾瀹炲彧闇瑕佹墽琛屼竴涓驚鐜嵆鍙細<br /><br /><logic:iterate id=" contact " name=" FormName " property=" contact " indexid="index"><br /><br /><html:text name=" contact " property="userId" indexed="true"><br /><br /><html:text name=" contact " property="email" indexed="true"><br /><br /></html:text><br /><br />榪欓噷鎴戜滑鍐嶈瑙d竴涓嬶紝浠g爜涓嚭鐜扮殑鈥?contact 鈥濓紙綰㈣壊錛夐兘鏄?ActionForm 涓殑 List鏁版嵁綾誨瀷鍙橀噺鍚嶇О錛岃紜繚涓鑷達紝璇蜂笉瑕佹洿鏀瑰悕縐幫紝榪欎篃鏄柟渚挎彁浜ゅ埌鍚庡彴鐨勬暟鎹帴鏀躲傗?FormName 鈥濅負鍦?struts-config涓0鏄庣殑 ActionForm 鍚嶇О銆?indexed="true" 鍙互紜繚鐢熸垚鐨?html 鍏冪礌鐨勫悕縐板敮涓錛屼笉瑕佺己灝戣繖涓0鏄庛備互涓婄殑Jsp 浠g爜錛屼綘涔熷彲浠ヤ嬌鐢?JSTL 鏉ュ畬鎴愶紝灝辯湅浣犱範鎯浣曚簡銆?br /><br />閫氳繃浠ヤ笂姝ラ錛屾垜浠畬鎴愪簡澶氳鏁版嵁鐨勬彁浜ゆ墍鏈夌幆鑺傦紝榪欐牱 Struts 灝變細瀹屾垚鍏朵粬鎵鏈夌殑浜嬫儏錛屾垜浠殑浠g爜閫昏緫鍜屽疄鐜頒篃綆鍗曞浜嗐?br /><br />鎬葷粨錛氶氳繃浠ヤ笂涓や釜渚嬪瓙錛岀浉浠ヤ俊瀵?ActionForm 涓嬌鐢?JavaBean 鍜?List 綾誨瀷鏁版嵁涓嶄細鍐嶉檶鐢燂紝鍚屾椂浣跨敤 Map綾誨瀷錛岃繖鏍峰彲鍒涘緩鏇村ソ鐨?ActionForm 璁捐錛屽叧浜?MapForm 錛岃鍙傝僪ttp://www.jetmaven.net/documents/j_mapformInStruts.php 銆備笉榪囧紩鍏ヨ繖縐嶆柟寮忓悗錛屽湪Validator 鏂歸潰浣犲彲鑳借鑺辯偣鑴戠瓔鍟︼紙濡傞氳繃 XDoclet 鐢熸垚 Validator鏂囦歡鍙兘鍔熻兘涓嶅叏錛夛紝鍙兘浣犻渶瑕佹墜鍐欎竴浜涗唬鐮佹潵瀹屾垚鐩稿叧宸ヤ綔</html:text></logic:iterate></html:text><img src ="http://m.tkk7.com/juhongtao/aggbug/87619.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/juhongtao/" target="_blank">javaGrowing</a> 2006-12-14 09:28 <a href="http://m.tkk7.com/juhongtao/archive/2006/12/14/87619.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎵╁睍Strutshttp://m.tkk7.com/juhongtao/archive/2005/12/30/25994.htmljavaGrowingjavaGrowingFri, 30 Dec 2005 01:48:00 GMThttp://m.tkk7.com/juhongtao/archive/2005/12/30/25994.htmlhttp://m.tkk7.com/juhongtao/comments/25994.htmlhttp://m.tkk7.com/juhongtao/archive/2005/12/30/25994.html#Feedback0http://m.tkk7.com/juhongtao/comments/commentRss/25994.htmlhttp://m.tkk7.com/juhongtao/services/trackbacks/25994.html浣滆咃細Sunil Patil
緲昏瘧錛?a target="_new">loryliu


鐗堟潈澹版槑錛氬彲浠ヤ換鎰忚漿杞斤紝杞澆鏃惰鍔″繀浠ヨ秴閾炬帴褰㈠紡鏍囨槑鏂囩珷鍘熷鍑哄鍜屼綔鑰呬俊鎭強鏈0鏄?br>浣滆?
Sunil Patil;loryliu
鍘熸枃鍦板潃:
http://www.onjava.com/pub/a/onjava/2004/11/10/ExtendingStruts.html
涓枃鍦板潃:
http://www.matrix.org.cn/resource/article/43/43857_Struts.html
鍏抽敭璇嶏細 extending Struts


綆浠?/span>

鎴? 瑙佽繃璁稿欏圭洰寮鍙戣呭疄鐜拌嚜宸變笓鏈夌殑MVC妗嗘灦銆傝繖浜涘紑鍙戣呭茍涓嶆槸鍥犱負鎯沖疄鐜頒笉鍚屼簬Struts鐨勬煇浜涘姛鑳斤紝鑰屾槸榪樻病鏈夋剰璇嗗埌鎬庝箞鍘繪墿灞昐truts銆傞氳繃 寮鍙戣嚜宸辯殑MVC妗嗘灦錛屼綘鍙互鎺屾帶鍏ㄥ眬錛屼絾鍚屾椂榪欎篃鎰忓懗鐫浣犲繀欏諱粯鍑哄緢澶х殑浠d環錛涘湪欏圭洰璁″垝寰堢揣鐨勬儏鍐典笅涔熻鏍規湰灝變笉鍙兘瀹炵幇銆?br>
Struts涓嶄絾鍔熻兘寮哄ぇ涔熸槗浜庢墿灞曘備綘鍙互閫氳繃涓夌鏂瑰紡鏉ユ墿灞昐truts:

1.PlugIn錛氬湪搴旂敤鍚姩鎴栧叧闂椂欏繪墽琛屾煇涓氬姟閫昏緫錛屽垱寤轟綘鑷繁鐨凱lugIn綾?br>
2.RequestProcessor錛氬湪璇鋒眰澶勭悊闃舵涓涓壒瀹氱偣嬈叉墽琛屾煇涓氬姟閫昏緫錛屽垱寤轟綘鑷繁鐨凴equestProcessor銆備緥濡傦細浣犳兂緇ф壙RequestProcessor鏉ユ鏌ョ敤鎴風櫥褰曞強鍦ㄦ墽琛屾瘡涓姹傛椂浠栨槸鍚︽湁鏉冮檺鎵ц鏌愪釜鍔ㄤ綔銆?br>
3.ActionServlet錛氬湪搴旂敤鍚姩鎴栧叧闂垨鍦ㄨ姹傚鐞嗛樁孌墊鎵ц鏌愪笟鍔¢昏緫錛岀戶鎵緼ctionServlet綾匯備絾鏄繀欏諱笖鍙兘鍦≒ligIn鍜孯equestProcessor閮戒笉鑳芥弧瓚充綘鐨勯渶姹傛椂鍊欑敤銆?br>
鏈枃浼氬垪涓句竴涓畝鍗曠殑Struts搴旂敤鏉ョず鑼冨浣曚嬌鐢ㄤ互涓婁笁縐嶆柟寮忔墿灞昐truts銆傚湪鏈枃鏈熬璧勬簮鍖烘湁姣忕鏂瑰紡鐨勫彲涓嬭澆鏍蜂緥婧愪唬鐮併係truts Validation 妗嗘灦鍜?Tiles 妗嗘灦鏄渶鎴愬姛涓や釜鐨凷truts鎵╁睍渚嬪瓙銆?br>
鎴戞槸鍋囪璇昏呭凡緇忕啛鎮塖truts妗嗘灦騫剁煡閬撴庢牱浣跨敤瀹冨垱寤虹畝鍗曠殑搴旂敤銆傚鎯充簡瑙f洿澶氭湁鍏砈truts鐨勮祫鏂欒鍙傝璧勬簮鍖恒?br>
PlugIn

鏍規嵁Struts鏂囨。錛屸淧lugIn鏄竴涓』鍦ㄥ簲鐢ㄥ惎鍔ㄥ拰鍏抽棴鏃墮渶琚氱煡鐨勬ā鍧楀畾鍒惰祫婧愭垨鏈嶅姟閰嶇疆鍖呪濄傝繖灝辨槸璇達紝浣犲彲浠ュ垱寤轟竴涓被錛屽畠瀹炵幇PlugIn鐨勬帴鍙d互渚垮湪搴旂敤鍚姩鍜屽叧闂椂鍋氫綘鎯寵鐨勪簨銆?br>
鍋? 濡傚垱寤轟簡涓涓獁eb搴旂敤錛屽叾涓嬌鐢℉ibernate鍋氫負鎸佷箙鍖栨満鍒訛紱褰撳簲鐢ㄤ竴鍚姩錛屽氨闇鍒濆鍖朒inernate錛岃繖鏍峰湪web搴旂敤鎺ユ敹鍒扮涓涓姹? 鏃訛紝Hibernate宸茶閰嶇疆瀹屾瘯騫跺緟鍛姐傚悓鏃跺湪搴旂敤鍏抽棴鏃惰鍏抽棴Hibernate銆傝窡鐫浠ヤ笅涓ゆ鍙互瀹炵幇Hibernate PlugIn鐨勯渶姹傘?br>
1.鍒涘緩涓涓疄鐜癙lugIn鎺ュ彛鐨勭被錛屽涓嬶細

public class HibernatePlugIn implements PlugIn{
        private String configFile;
        // This method will be called at application shutdown time
        public void destroy() {
                System.out.println("Entering HibernatePlugIn.destroy()");
                //Put hibernate cleanup code here
                System.out.println("Exiting HibernatePlugIn.destroy()");
        }
        //This method will be called at application startup time
        public void init(ActionServlet actionServlet, ModuleConfig config)
                throws ServletException {
                System.out.println("Entering HibernatePlugIn.init()");
                System.out.println("Value of init parameter " +
                                    getConfigFile());
                System.out.println("Exiting HibernatePlugIn.init()");
        }
        public String getConfigFile() {
                return name;
        }
        public void setConfigFile(String string) {
                configFile = string;
        }
}


瀹炵幇PlugIn鎺ュ彛鐨勭被蹇呴』鏄疄鐜頒互涓嬩袱涓柟娉曪細
init() 鍜宒estroy().銆傚湪搴旂敤鍚姩鏃秈nit()琚皟鐢紝鍏抽棴destroy()琚皟鐢ㄣ係truts鍏佽浣犱紶鍏ュ垵濮嬪弬鏁扮粰浣犵殑PlugIn綾伙紱涓轟簡浼? 鍏ュ弬鏁頒綘蹇呴』鍦≒lugIn綾婚噷涓烘瘡涓弬鏁板垱寤轟竴涓被浼糐avaBean褰㈠紡鐨剆etter鏂規硶銆傚湪HibernatePlugIn綾婚噷錛屾浼犲叆 configFile鐨勫悕瀛楄屼笉鏄湪搴旂敤閲屽皢瀹冪‖緙栫爜榪涘幓

2.鍦╯truts-condig.xml閲岄潰鍔犲叆浠ヤ笅鍑犺鍛婄煡Struts榪欎釜鏂扮殑PlugIn

<struts-config>
        ...
        <!-- Message Resources -->
        <message-resources parameter=
          "sample1.resources.ApplicationResources"/>

        <!-- Declare your plugins -->
        <plug-in className="com.sample.util.HibernatePlugIn">
                <set-property property="configFile"
                   value="/hibernate.cfg.xml"/>
        </plug-in>
</struts-config>

ClassName 灞炴ф槸瀹炵幇PlugIn鎺ュ彛綾葷殑鍏ㄥ悕銆備負姣忎竴涓垵濮嬪寲浼犲叆PlugIn綾葷殑鍒濆鍖栧弬鏁板鍔犱竴涓?lt;set-property>鍏冪礌銆傚湪榪欎釜渚嬪瓙 閲岋紝浼犲叆config鏂囨。鐨勫悕縐幫紝鎵浠ュ鍔犱簡涓涓猚onfig鏂囨。璺緞鐨?lt;set-property>鍏冪礌銆?br>
Tiles鍜孷alidator妗嗘灦閮芥槸鍒╃敤PlugIn緇欏垵濮嬪寲璇誨叆閰嶇疆鏂囦歡銆傚彟澶栦袱涓綘榪樺彲浠ュ湪PlugIn綾婚噷鍋氱殑浜嬫儏鏄細

鍋囧搴旂敤渚濊禆浜庢煇閰嶇疆鏂囦歡錛岄偅涔堝彲浠ュ湪PlugIn綾婚噷媯鏌ュ叾鍙敤鎬э紝鍋囧閰嶇疆鏂囦歡涓嶅彲鐢ㄥ垯鎶涘嚭ServletException銆傝繖灝嗗鑷碅ctionServlet涓嶅彲鐢ㄣ?br>
PlugIn鎺ュ彛鐨刬nit()鏂規硶鏄綘鏀瑰彉ModuleConfig鏂規硶鐨勬渶鍚庢満浼氾紝ModuleConfig鏂規硶鏄弿榪板熀浜嶴truts妯″瀷闈欐侀厤緗俊鎭殑闆嗗悎銆備竴鏃lugIn琚鐞嗗畬姣曪紝Struts灝變細灝哅oduleCOnfig鍐葷粨璧鋒潵銆?br>
璇鋒眰鏄浣曡澶勭悊鐨?/span>

ActionServlet 鏄疭truts妗嗘灦閲屽敮涓涓涓猄ervlet錛屽畠璐熻矗澶勭悊鎵鏈夎姹傘傚畠鏃犺浣曟椂鏀跺埌涓涓姹傦紝閮戒細棣栧厛璇曠潃涓虹幇鏈夎姹傛壘鍒頒竴涓瓙搴旂敤銆備竴鏃﹀瓙搴旂敤琚壘鍒幫紝 瀹冧細涓哄叾鐢熸垚涓涓猂equestProcessor瀵硅薄錛屽茍璋冪敤浼犲叆HttpServletRequest鍜孒ttpServletResponse涓哄弬 鏁扮殑process()鏂規硶銆?br>
澶ч儴鍒嗚澶勭悊閮芥槸鍦≧equestProcessor.process()鍙戠敓鐨勩侾rocess()鏂規硶 鏄互妯℃澘鏂規硶錛圱emplate Method錛夌殑璁捐妯″紡鏉ュ疄鐜扮殑錛屽叾涓湁瀹屾垚request澶勭悊鐨勬瘡涓楠ょ殑鏂規硶錛涙墍鏈夎繖浜涙柟娉曢兘浠巔rocess()鏂規硶欏哄簭璋冪敤銆備緥濡傦紝瀵繪壘褰撳墠璇? 姹傜殑ActionForm綾誨拰媯鏌ュ綋鍓嶇敤鎴鋒槸鍚︽湁鏉冮檺鎵цaction mapping閮芥湁鍑犱釜鍗曠嫭鐨勬柟娉曘傝繖緇欐垜浠彁渚涗簡鏋佸ぇ鐨勫脊鎬х┖闂淬係truts鐨凴equestProcessor瀵規瘡涓姹傚鐞嗘楠ら兘鎻愪緵浜嗛粯璁ょ殑瀹? 鐜版柟娉曘傝繖鎰忓懗鐫錛屼綘鍙互閲嶅啓浣犳劅鍏磋叮鐨勬柟娉曪紝鑰屽叾浣欏墿涓嬬殑淇濈暀榛樿瀹炵幇銆備緥濡傦紝Struts榛樿璋冪敤request.isUserInRole()媯鏌? 鐢ㄦ埛鏄惁鏈夋潈闄愭墽琛屽綋鍓嶇殑ActionMapping錛屼絾濡傛灉浣犻渶瑕佷粠鏁版嵁搴撲腑鏌ユ壘錛岄偅涔堜綘瑕佸仛鐨勫氨鏄噸鍐檖rocessRoles()鏂規硶錛屽茍鏍規嵁鐢ㄦ埛 瑙掕壊榪斿洖true 鎴?false銆?br>
棣栧厛鎴戜滑鐪嬩竴涓媝rocess()鏂規硶鐨勯粯璁ゅ疄鐜版柟寮忥紝鐒跺悗鎴戝皢瑙i噴RequestProcessor綾婚噷鐨勬瘡涓粯璁ょ殑鏂規硶錛屼互渚夸綘鍐沖畾瑕佷慨鏀硅姹傚鐞嗙殑鍝竴閮ㄥ垎銆?br>
public void process(HttpServletRequest request,
                        HttpServletResponse response)
    throws IOException, ServletException {
        // Wrap multipart requests with a special wrapper
        request = processMultipart(request);
        // Identify the path component we will
        // use to select a mapping
        String path = processPath(request, response);
        if (path == null) {
            return;
        }
        if (log.isDebugEnabled()) {
            log.debug("Processing a '" + request.getMethod() +
                      "' for path '" + path + "'");
        }
        // Select a Locale for the current user if requested
        processLocale(request, response);
        // Set the content type and no-caching headers
        // if requested
        processContent(request, response);
        processNoCache(request, response);
        // General purpose preprocessing hook
        if (!processPreprocess(request, response)) {
            return;
       }
        // Identify the mapping for this request
        ActionMapping mapping =
            processMapping(request, response, path);
        if (mapping == null) {
            return;
        }
        // Check for any role required to perform this action
        if (!processRoles(request, response, mapping)) {
            return;
        }
        // Process any ActionForm bean related to this request
        ActionForm form =
            processActionForm(request, response, mapping);
        processPopulate(request, response, form, mapping);
        if (!processValidate(request, response, form, mapping)) {
            return;
        }
        // Process a forward or include specified by this mapping
        if (!processForward(request, response, mapping)) {
            return;
        }
        if (!processInclude(request, response, mapping)) {
            return;
        }
        // Create or acquire the Action instance to
        // process this request
        Action action =
            processActionCreate(request, response, mapping);
        if (action == null) {
            return;
        }
        // Call the Action instance itself
        ActionForward forward =
            processActionPerform(request, response,
                                action, form, mapping);
        // Process the returned ActionForward instance
        processForwardConfig(request, response, forward);
    }



1銆乸rocessMultipart(): 鍦? 榪欎釜鏂規硶涓紝Struts璇誨彇request浠ユ壘鍑篶ontentType鏄惁涓簃ultipart/form-data銆傚亣濡傛槸錛屽垯瑙f瀽騫跺皢鍏舵墦鍖呮垚涓 涓疄鐜癏ttpServletRequest鐨勫寘銆傚綋浣犳垚鐢熶竴涓斁緗暟鎹殑HTML FORM鏃訛紝request鐨刢ontentType榛樿鏄痑pplication/x-www-form-urlencoded銆備絾鏄鏋滀綘鐨刦orm 鐨刬nput綾誨瀷鏄疐ILE-type鍏佽鐢ㄦ埛涓婅澆鏂囦歡錛岄偅涔堜綘蹇呴』鎶奻orm鐨刢ontentType鏀逛負multipart/form-data銆傚 榪欐牱鍋氾紝浣犳案榪滀笉鑳介氳繃HttpServletRequest鐨刧etParameter()鏉ヨ鍙栫敤鎴鋒彁浜ょ殑form鍊鹼紱浣犲繀欏諱互 InputStream鐨勫艦寮忚鍙杛equest錛岀劧鍚庤В鏋愬畠寰楀埌鍊箋?br>
2銆乸rocessPath(): 鍦ㄨ繖涓柟娉曚腑錛孲truts灝嗚鍙杛equest鐨刄RI浠ュ垽鏂敤鏉ュ緱鍒癆ctionMapping鍏冪礌鐨勮礬寰勩?br>
3銆乸rocessLocale(): 鍦ㄨ繖涓柟娉曚腑錛孲truts灝嗗緱鍒板綋鍓峳equest鐨凩ocale錛汱ocale鍋囧琚厤緗紝灝嗕綔涓? org.apache.struts.action.LOCALE灞炴х殑鍊艱瀛樺叆HttpSession銆傝繖涓柟娉曠殑闄勪綔鐢ㄦ槸HttpSession浼氳 鍒涘緩銆傚亣濡備綘涓嶆兂姝や簨鍙戠敓錛屽彲灝嗗湪struts-config.xml 鏂囦歡閲孋ontrollerConfig鐨刲ocal灞炴ц緗負false,濡備笅錛?br>
<controller>
        <set-property property="locale" value="false"/>
</controller>


4銆乸rocessContent()錛?/b>閫氳繃璋冪敤response.setContentType()璁劇疆response鐨刢ontentType銆傝繖涓柟娉曢鍏堜細璇曠潃鐨勫緱鍒伴厤緗湪struts-config.xml閲岀殑contentType銆傞粯璁や負text/html錛岄噸鍐欐柟娉曞涓嬶細
<controller>
        <set-property property="contentType" value="text/plain"/>
</controller>


5銆乸rocessNoCache()錛?/b>Struts灝嗕負姣忎釜response鐨勮緗互涓嬩笁涓猦eader錛屽亣濡傚凡鍦╯truts 鐨刢onfig.xml灝嗛厤緗負no-cache銆?br>
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 1);


鍋囧浣犳兂璁劇疆涓簄o-cache header錛屽湪struts-config.xml涓姞濡備互涓嬪嚑琛?br>
<controller>
        <set-property property="noCache" value="true"/>
</controller>


6銆乸rocessPreprocess()錛?/b>榪欐槸涓涓竴鑸剰涔夌殑棰勫鐞唄ook錛屽叾鍙瀛愮被閲嶅啓銆傚湪RequestProcessor閲岀殑瀹炵幇浠涔堥兘娌℃湁鍋氾紝鎬繪槸榪斿洖true銆傚姝ゆ柟娉曡繑鍥瀎alse浼氫腑鏂姹傚鐞嗐?br>
7銆乸rocessMapping():榪欎釜鏂規硶浼氬埄鐢╬ath淇℃伅鎵懼埌ActionMapping瀵硅薄銆侫ctionMapping瀵硅薄鍦╯truts-config.xml file鏂囦歡閲岃〃紺轟負<action>
<action path="/newcontact" type="com.sample.NewContactAction"
        name="newContactForm" scope="request">
        <forward name="sucess" path="/sucessPage.do"/>
        <forward name="failure" path="/failurePage.do"/>
</action>


ActionMapping鍏冪礌鍖呭惈浜嗗Action綾葷殑鍚嶇О鍙婂湪璇鋒眰涓敤鍒扮殑ActionForm鐨勪俊鎭紝鍙﹀榪樻湁閰嶇疆鍦ㄥ綋鍓岮ctionMapping鐨勯噷鐨凙ctionForwards淇℃伅銆?br>
8銆乸rocessRoles(): Struts鐨剋eb 搴旂敤瀹夊叏鎻愪緵浜嗕竴涓璇佹満鍒躲傝繖灝辨槸璇達紝涓鏃︾敤鎴風櫥褰曞埌瀹瑰櫒錛孲truts鐨刾rocessRoles()鏂規硶閫氳繃璋冪敤request.isUserInRole()鍙互媯鏌ヤ粬鏄惁鏈夋潈闄愭墽琛岀粰瀹氱殑ActionMapping銆?br>        <action path="/addUser" roles="administrator"/>

鍋囧浣犳湁涓涓狝ddUserAction錛岄檺鍒跺彧鏈塧dministrator鏉冮檺鐨勭敤鎴鋒墠鑳芥柊娣誨姞鐢ㄦ埛銆備綘鎵瑕佸仛鐨勫氨鏄湪AddUserAction 鐨刟ction鍏冪礌閲屾坊鍔犱竴涓間負administrator鐨剅ole灞炴с?br>
9銆乸rocessActionForm()錛?/b>姣忎釜ActionMapping閮芥湁涓涓笌瀹冨叧鑱旂殑ActionForm綾匯俿truts鍦ㄥ鐞咥ctionMapping鏃訛紝浠栦細浠?lt;action>閲宯ame灞炴ф壘鍒扮浉鍏崇殑ActionForm綾葷殑鍊箋?br>
<form-bean name="newContactForm" 
           type="org.apache.struts.action.DynaActionForm">
                <form-property name="firstName"
                          type="java.lang.String"/>
                <form-property name="lastName"
                          type="java.lang.String"/>
</form-bean>


鍦ㄨ繖涓緥瀛愰噷錛岄鍏堜細媯鏌rg.apache.struts.action.DynaActionForm綾葷殑瀵硅薄鏄惁鍦╮equest 鑼冨洿鍐呫傚鏄紝鍒欎嬌鐢ㄥ畠錛屽惁鍒欏垱寤轟竴涓柊鐨勫璞″茍鍦╮equest鑼冨洿鍐呰緗畠銆?br>
10銆乸rocessPopulate():錛?/b>鍦ㄨ繖涓柟娉曢噷錛孲truts灝嗗尮閰嶇殑request parameters鍊煎~鍏ctionForm綾葷殑瀹炰緥鍙橀噺涓?br>
11銆乸rocessValidate()錛?/b>Struts灝嗚皟鐢ˋctionForm鐨剉alidate()鏂規硶銆傚亣濡倂alidate()榪斿洖ActionErrors錛孲truts灝嗙敤鎴瘋漿鍒扮敱<action>閲岀殑input灞炴ф爣紺虹殑欏甸潰銆?br>
12銆乸rocessForward() and processInclude()錛?/b>鍦ㄨ繖涓や釜鏂規硶閲岋紝Struts媯鏌?lt;action>鍏冪礌鐨刦orward鍜宨nclude灞炴х殑鍊鹼紝鍋囧鏈夐厤緗紝鍒欐妸forward鍜宨nclude 璇鋒眰鏀懼湪閰嶇疆鐨勯〉闈㈠唴銆?br>
<action forward="/Login.jsp" path="/loginInput"/>
        <action include="/Login.jsp" path="/loginInput"/>


浣? 鍙互浠庝粬浠殑鍚嶅瓧鐪嬪嚭鍏朵笉鍚屼箣澶勩俻rocessForward()璋冪敤RequestDispatcher.forward(),錛? processInclude()璋冪敤RequestDispatcher.include()銆傚亣濡備綘鍚屾椂閰嶇疆浜唎rward 鍜宨nclude 灞炴э紝Struts鎬諱細璋冪敤forward錛屽洜涓篺orward,鏄鍏堣澶勭悊鐨勩?br>
13銆乸rocessActionCreate()錛?/b>榪欎釜鏂規硶浠?lt;action>鐨則ype灞炴у緱鍒癆ction綾誨悕錛屽茍鍒涘緩榪斿洖瀹冪殑瀹炰緥銆傚湪榪欓噷渚嬪瓙涓璼truts灝嗗垱寤轟竴涓猚om.sample.NewContactAction綾葷殑瀹炰緥銆?br>
14銆乸rocessActionPerform()錛?/b>榪欎釜鏂規硶璋冪敤Action 綾葷殑execute()鏂規硶錛屽叾涓湁浣犲啓鍏ョ殑涓氬姟閫昏緫銆?br>
15銆乸rocessForwardConfig()錛?/b>Action綾葷殑execute()灝嗕細榪斿洖涓涓狝ctionForward綾誨瀷鐨勫璞★紝鎸囧嚭鍝竴欏甸潰灝嗗睍紺虹粰鐢ㄦ埛銆傚洜姝truts灝嗕負榪欎釜欏甸潰鍒涘緩RequestDispatchet錛岀劧鍚庡啀璋冪敤RequestDispatcher.forward()鏂規硶銆?br>
浠? 涓婂垪鍑虹殑鏂規硶瑙i噴浜哛equestProcessor鍦ㄨ姹傚鐞嗙殑姣忔榛樿瀹炵幇鍙婂悇涓楠ゆ墽琛岀殑欏哄簭銆傛濡備綘鎵瑙侊紝RequestProcessor寰堟湁 寮規э紝瀹冨厑璁鎬綘閫氳繃璁劇疆<controller>閲岀殑灞炴ф潵閰嶇疆瀹冦備緥濡傦紝鍋囧浣犵殑搴旂敤灝嗙敓鎴怷ML鍐呭鑰屼笉鏄疕TML錛屼綘鍙互閫氳繃璁劇疆 controller鐨勬煇涓睘鎬ф潵閫氱煡Struts銆?br>
鍒涘緩浣犺嚜宸辯殑RequestProcessor

浠? 浠ヤ笂鍐呭鎴戜滑宸茬粡鏄庣櫧浜哛equestProcessor鐨勯粯璁ゅ疄鐜版槸鎬庢牱宸ヤ綔鐨勶紝鐜板湪鎴戝皢閫氳繃鍒涘緩浣犺嚜宸辯殑RequestProcessor.灞曠ず涓涓? 鎬庢牱鑷畾涔塕equestProcessor鐨勪緥瀛愩備負浜嗘紨紺哄垱寤轟竴涓嚜瀹氫箟RequestProcessor錛屾垜灝嗕慨鏀逛緥瀛愬疄鐜頒互涓嬭繛涓笟鍔¢渶姹傦細

鎴戜滑瑕佸垱寤轟竴涓狢ontactImageAction綾伙紝瀹冨皢鐢熸垚images鑰屼笉鏄竴鑸殑HTMl欏甸潰

鍦ㄥ鐞嗚繖涓姹備箣鍓嶏紝灝嗛氳繃媯鏌ession閲岀殑userName灞炴ф潵紜鐢ㄦ埛鏄惁鐧誨綍銆傚亣濡傛灞炴ф病鏈夎鎵懼埌錛屽垯灝嗙敤鎴瘋漿鍒扮櫥褰曢〉闈€?br>

鍒嗕袱姝ユ潵瀹炵幇浠ヤ笂榪炰釜涓氬姟闇姹傘?br>鍒涘緩浣犺嚜宸辯殑CustomRequestProcessor綾伙紝瀹冨皢緇ф壙RequestProcessor綾伙紝濡備笅錛?br>
public class CustomRequestProcessor
    extends RequestProcessor {
        protected boolean processPreprocess (
            HttpServletRequest request,
            HttpServletResponse response) {
            HttpSession session = request.getSession(false);
        //If user is trying to access login page
        // then don't check
        if( request.getServletPath().equals("/loginInput.do")
            || request.getServletPath().equals("/login.do") )
            return true;
        //Check if userName attribute is there is session.
        //If so, it means user has allready logged in
        if( session != null &&
        session.getAttribute("userName") != null)
            return true;
        else{
            try{
                //If no redirect user to login Page
                request.getRequestDispatcher
                    ("/Login.jsp").forward(request,response);
            }catch(Exception ex){
            }
        }
        return false;
    }

    protected void processContent(HttpServletRequest request,
                HttpServletResponse response) {
            //Check if user is requesting ContactImageAction
            // if yes then set image/gif as content type
            if( request.getServletPath().equals("/contactimage.do")){
                response.setContentType("image/gif");
                return;
            }
        super.processContent(request, response);
    }
}


鍦–ustomRequestProcessor 綾葷殑processPreprocess鏂規硶閲岋紝媯鏌ession鐨剈serName灞炴э紝鍋囧娌℃湁鎵懼埌錛屽皢鐢ㄦ埛杞埌鐧誨綍欏甸潰銆?br>
瀵? 浜庝駭鐢焛mages浣滀負ContactImageAction綾葷殑杈撳嚭錛屽繀欏昏閲嶅啓processContent鏂規硶銆傞鍏堟鏌ュ叾request鏄惁璇鋒眰 /contactimage璺緞錛屽鏄垯璁劇疆contentType涓篿mage/gif錛涘惁鍒欎負text/html銆?br>
鍔犲叆浠ヤ笅鍑犺浠g爜鍒皊ruts-config.xml鏂囦歡閲岀殑<action-mapping>鍚庨潰錛屽憡鐭truts 錛孋ustomRequestProcessor搴旇琚敤浣淩equestProcessor綾?br>
<controller>
        <set-property  property="processorClass"
        value="com.sample.util.CustomRequestProcessor"/>
</controller>


璇? 娉ㄦ剰錛屽亣濡備綘鍙槸寰堝皯鐢熸垚contentType涓嶆槸text/html杈撳嚭鐨凙ction綾伙紝閲嶅啓processContent()灝辨病鏈夐棶棰樸傚涓嶆槸 榪欑鎯呭喌錛屼綘蹇呴』鍒涘緩涓涓猄truts瀛愮郴緇熸潵澶勭悊鐢熸垚image  Action鐨勮姹傚茍璁劇疆contentType涓篿mage/gif

Title妗嗘灦浣跨敤鑷繁鐨凴equestProcessor鏉ヨ楗癝truts鐢熸垚鐨勮緭鍑恒?br>
ActionServlet

鍋囧浣犱粩緇嗙爺絀禨truts web搴旂敤鐨剋eb.xml鏂囦歡錛屽畠鐪嬩笂鍘誨儚榪欐牱錛?br>
<web-app >
        <servlet>
            <servlet-name>action=</servlet-name>
            <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
            <!-- All your init-params go here-->
        </servlet>
        <servlet-mapping>
            <servlet-name>action</servlet-name>
            <url-pattern>*.do</url-pattern>
        </servlet-mapping>
</web-app >


榪? 灝辨槸璇達紝ActionServlet璐熻矗澶勭悊鎵鏈夊彂鍚慡truts鐨勮姹傘備綘鍙互鍒涘緩ActionServlet鐨勪竴涓瓙綾伙紝鍋囧浣犳兂鍦ㄥ簲鐢ㄥ惎鍔ㄥ拰鍏抽棴鏃? 鎴栨瘡嬈¤姹傛椂鍋氭煇浜涗簨鎯呫備絾鏄綘蹇呴』鍦ㄧ戶鎵緼ctionServlet綾誨墠鍒涘緩PlugIn 鎴?RequestProcessor銆傚湪Servlet 1.1鍓嶏紝Title妗嗘灦鏄熀浜庣戶鎵緼ctionServlet綾繪潵瑁呴グ涓涓敓鎴愮殑response銆備絾浠?.1寮濮嬶紝灝變嬌鐢? TilesRequestProcessor綾匯?br>
緇撹

寮鍙戜綘鑷繁鐨凪VC妯″瀷鏄竴涓緢澶х殑鍐沖績鈥斺斾綘蹇呴』鑰冭檻寮鍙戝拰緇存姢浠g爜鐨勬椂闂村拰璧勬簮銆係truts鏄竴涓姛鑳藉己澶т笖紼沖畾鐨勬鏋訛紝浣犲彲浠ヤ慨鏀瑰畠浠ヤ嬌鍏舵弧瓚充綘澶ч儴鍒嗙殑涓氬姟闇姹傘?br>
鍙︿竴鏂歸潰錛屼篃涓嶈杞繪槗鍦板喅瀹氭墿灞昐truts銆傚亣濡備綘鍦≧equestProcessor閲屾斁鍏ヤ竴浜涗綆鏁堢巼鐨勪唬鐮侊紝榪欎簺浠g爜灝嗗湪姣忔璇鋒眰鏃舵墽琛屽茍澶уぇ鍦伴檷浣庢暣涓簲鐢ㄧ殑鏁堢巼銆傚綋鐒舵繪湁鍒涘緩浣犺嚜宸辯殑MVC妗嗘灦姣旀墿灞昐truts鏇村ソ鐨勬儏鍐點?br>
璧勬簮
涓嬭澆鏈枃婧愮爜錛歔涓嬭澆鏂囦歡]
Struts涓婚〉
"Jakarta Struts妗嗘灦浠嬬粛"
"瀛︿範Jakarta Struts 1.1"


Sunil Pail宸蹭粠浜婮2EE鍥涘勾錛岀幇浠婁笌IBM瀹為獙瀹ゅ悎浣溿?img src ="http://m.tkk7.com/juhongtao/aggbug/25994.html" width = "1" height = "1" />

]]>
struts涓枃鐨勮В鍐?/title><link>http://m.tkk7.com/juhongtao/archive/2005/12/27/25587.html</link><dc:creator>javaGrowing</dc:creator><author>javaGrowing</author><pubDate>Tue, 27 Dec 2005 07:56:00 GMT</pubDate><guid>http://m.tkk7.com/juhongtao/archive/2005/12/27/25587.html</guid><wfw:comment>http://m.tkk7.com/juhongtao/comments/25587.html</wfw:comment><comments>http://m.tkk7.com/juhongtao/archive/2005/12/27/25587.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/juhongtao/comments/commentRss/25587.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/juhongtao/services/trackbacks/25587.html</trackback:ping><description><![CDATA[<span id="wweoewq" class="javascript" id="text9057"> 杞嚜 <a target="_blank" class="ilink">www.javaresearch.org</a><br>浣滆?fishandfly <br><br>1.浣?font style="background-color: rgb(255, 255, 0);"><b>ApplicationResources.properties</b></font>鏀寔涓枃<br>寤虹珛涓涓狝pplicationResources_ISO.properties鏂囦歡錛屾妸搴旂敤紼嬪簭鐢ㄧ殑message閮藉啓榪涘幓錛岀劧鍚庡湪dos涓嬫墽琛岃繖涓懡浠わ紝<br>native2ascii -encoding gb2312 ApplicationResources_ISO.properties <font style="background-color: rgb(255, 255, 0);"><b>ApplicationResources.properties</b></font><br>榪欐牱灝變細灝咺SO緙栫爜鐨凙pplicationResources杞崲鎴怗B2312緙栫爜鐨勬牸寮忎簡錛屽悓鏃朵繚瀛樺埌<font style="background-color: rgb(255, 255, 0);"><b>ApplicationResources.properties</b></font>.<br>native2ascii榪欎釜宸ュ叿鏄痡dk鑷甫鐨勪竴涓笢涓滐紝鎵浠ュ鏋減ath閮借瀹氭紜氨鍙互鐩存帴榪愯浜嗭紝浣犲彲浠ュ湪$java_home$/bin涓嬫壘鍒頒粬銆?br>杞崲鍚庣殑涓枃綾諱技浜庤繖涓牱瀛?br>iso 鏍煎紡涓?錛歵j.type=鍟嗗搧杞︾被鍨?br>gb2312鏍煎紡涓?錛歵j.type=\u5546\u54c1\u8f66\u7c7b\u578b<br>鐒跺悗鍦╯truts-config.xml涓緗簲鐢ㄨ繖涓祫婧愭枃浠?br><message-resources parameter="com.huahang.tj.ApplicationResources" key="org.apache.struts.action.MESSAGE" /><br>寮鍙慾sp鏃跺湪jsp鐨勫紑澶村啓涓?lt;%@ page contentType="text/html; charset=gb2312" %>錛屽皢瀛楃闆嗚緗垚gb2312灝卞彲浠ヤ簡銆?br><br>2.浣挎暟鎹簱鎿嶄綔鏀寔涓枃銆?br>鏁版嵁搴撴搷浣滄敮鎸佷腑鏂囦竴鐩磋鎴戞瘮杈冨ご鐥涳紝浣嗘槸鎰熻阿鍠勮В浜鴻。鍚戞垜鎺ㄨ崘浜唚ww.chinaxp.org錛岃繖涓綉绔欐槸鐢╯truts妗嗘灦寮鍙戠殑錛岃屼笖<br>寮鏀炬簮鐮侊紝涓嬭澆浜嗘簮鐮佸悗鍙戠幇瀹冪殑涓枃澶勭悊寰楀緢濂斤紝闃呰閮ㄥ垎婧愮爜錛屾病鏈夊彂鐜頒粈涔堢壒孌婄殑瀛楃闆嗚漿鎹紝寰堢撼闂鳳紝鍋剁劧鐪嬪埌妤間笂緗戝弸<br>鐣欒█鐭ラ亾鍘熸潵servlet鍙互緇熶竴璁劇疆瀛楃杞崲銆俢hinaxp.org灝辨槸榪欎箞鍋氱殑銆?br>鍦╳eb.xml涓姞涓?br><filter><br><filter-name>Set Character Encoding</filter-name><br><filter-class>com.huahang.tj.struts.filters.SetCharacterEncodingFilter</filter-class><br><init-param><br><param-name>encoding</param-name><br><param-value>GB2312</param-value><br></init-param><br><init-param><br><param-name>ignore</param-name><br><param-value>true</param-value><br></init-param><br></filter><br><filter-mapping><br><filter-name>Set Character Encoding</filter-name><br><servlet-name>action</servlet-name><br></filter-mapping><br>榪欓噷浼氭秹鍙婁竴涓猙ean,婧愮爜濡備笅錛?br>/*<br>* XP Forum<br>* <br>* Copyright <img src="http://www.cjsdn.net/images/smiles/coffee_smile.gif" alt="Coffee" width="19"> 2002-2003 RedSoft Group. All rights reserved.<br>*<br>*/<br>package com.huahang.tj.struts.filters;<br><br>import javax.servlet.*;<br>import java.io.IOException;<br><br>/**<br>* <p>Filter that sets the character encoding to be used in parsing the<br>* incoming request, either unconditionally or only if the client did not<br>* specify a character encoding. Configuration of this filter is based on<br>* the following initialization parameters:</p><br>* <ul><br>* <li><strong>encoding</strong> - The character encoding to be configured<br>* for this request, either conditionally or unconditionally based on<br>* the <code>ignore</code> initialization parameter. This parameter<br>* is required, so there is no default.</li><br>* <li><strong>ignore</strong> - If set to "true", any character encoding<br>* specified by the client is ignored, and the value returned by the<br>* <code>selectEncoding()</code> method is set. If set to "false,<br>* <code>selectEncoding()</code> is called <strong>only</strong> if the<br>* client has not already specified an encoding. By default, this<br>* parameter is set to "true".</li><br>* </ul><br>*<br>* <p>Although this filter can be used unchanged, it is also easy to<br>* subclass it and make the <code>selectEncoding()</code> method more<br>* intelligent about what encoding to choose, based on characteristics of<br>* the incoming request (such as the values of the <code>Accept-Language</code><br>* and <code>User-Agent</code> headers, or a value stashed in the current<br>* user's session.</p><br>*<br>* @author <a href="mailto:jwtronics@yahoo.com">John Wong</a><br>*<br>* @version $Id: SetCharacterEncodingFilter.java,v 1.1 2002/04/10 13:59:27 johnwong Exp $<br>*/<br>public class SetCharacterEncodingFilter implements Filter {<br><br>// ----------------------------------------------------- Instance Variables<br><br>/**<br>* The default character encoding to set for requests that pass through<br>* this filter.<br>*/<br>protected String encoding = null;<br><br>/**<br>* The filter configuration object we are associated with. If this value<br>* is null, this filter instance is not currently configured.<br>*/<br>protected FilterConfig filterConfig = null;<br><br>/**<br>* Should a character encoding specified by the client be ignored?<br>*/<br>protected boolean ignore = true;<br><br>// --------------------------------------------------------- Public Methods<br><br>/**<br>* Take this filter out of service.<br>*/<br>public void destroy() {<br><br>this.encoding = null;<br>this.filterConfig = null;<br><br>}<br><br>/**<br>* Select and set (if specified) the character encoding to be used to<br>* interpret request parameters for this request.<br>*<br>* @param request The servlet request we are processing<br>* @param result The servlet response we are creating<br>* @param chain The filter chain we are processing<br>*<br>* @exception IOException if an input/output error occurs<br>* @exception ServletException if a servlet error occurs<br>*/<br>public void doFilter(ServletRequest request, ServletResponse response,<br>FilterChain chain)<br>throws IOException, ServletException {<br><br>// Conditionally select and set the character encoding to be used<br>if (ignore || (request.getCharacterEncoding() == null)) {<br>String encoding = selectEncoding(request);<br>if (encoding != null)<br>request.setCharacterEncoding(encoding);<br>}<br><br>// Pass control on to the next filter<br>chain.doFilter(request, response);<br><br>}<br><br>/**<br>* Place this filter into service.<br>*<br>* @param filterConfig The filter configuration object<br>*/<br>public void init(FilterConfig filterConfig) throws ServletException {<br><br>this.filterConfig = filterConfig;<br>this.encoding = filterConfig.getInitParameter("encoding");<br>String value = filterConfig.getInitParameter("ignore");<br>if (value == null)<br>this.ignore = true;<br>else if (value.equalsIgnoreCase("true"))<br>this.ignore = true;<br>else if (value.equalsIgnoreCase("yes"))<br>this.ignore = true;<br>else<br>this.ignore = false;<br><br>}<br><br>// ------------------------------------------------------ Protected Methods<br><br>/**<br>* Select an appropriate character encoding to be used, based on the<br>* characteristics of the current request and/or filter initialization<br>* parameters. If no character encoding should be set, return<br>* <code>null</code>.<br>* <p><br>* The default implementation unconditionally returns the value configured<br>* by the <strong>encoding</strong> initialization parameter for this<br>* filter.<br>*<br>* @param request The servlet request we are processing<br>*/<br>protected String selectEncoding(ServletRequest request) {<br><br>return (this.encoding);<br><br>}<br><br>}//EOC<br>鍔犱笂榪欎釜鍚庯紝鍦╝ction涓氨鍙互鐩存帴浠巉orm涓帴鏀秅b2312緙栫爜鐨勬暟鎹簡錛岃繑鍥炴椂鑷劧涔熸槸gb2312浜嗐?br>浣嗘槸榪欎釜濂藉儚闇瑕乻ervlet 2.2浠ヤ笂鐨勫鍣?br><br>緇煎悎涓婇潰鐨勬柟娉曪紝鎴戣В鍐充簡struts涓殑涓枃闂錛岀幇鍦ㄨ繕娌″彂鐜版柊鐨勯棶棰樸?br><br>鎴戠殑鐜鏄?br>windows2000 Professional,tomcat 4.04 , struts1.1b2 </span> <br><img src ="http://m.tkk7.com/juhongtao/aggbug/25587.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/juhongtao/" target="_blank">javaGrowing</a> 2005-12-27 15:56 <a href="http://m.tkk7.com/juhongtao/archive/2005/12/27/25587.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://qixiresort.com" target="_blank">亚洲成av人片在线观看天堂无码 </a>| <a href="http://97aimeili.com" target="_blank">少妇人妻偷人精品免费视频 </a>| <a href="http://iguasheng.com" target="_blank">看Aⅴ免费毛片手机播放</a>| <a href="http://xtolm.com" target="_blank">一个人看www在线高清免费看</a>| <a href="http://zgnyxx.com" target="_blank">亚洲电影免费在线观看</a>| <a href="http://gdfcjzx.com" target="_blank">在线毛片片免费观看</a>| <a href="http://jiuse54.com" target="_blank">国产AV无码专区亚洲AWWW</a>| <a href="http://8mav1000.com" target="_blank">9久热这里只有精品免费</a>| <a href="http://740740740.com" target="_blank">337p日本欧洲亚洲大胆裸体艺术</a>| <a href="http://c4665.com" target="_blank">香蕉视频在线观看免费</a>| <a href="http://22222xxx.com" target="_blank">亚洲第一黄色网址</a>| <a href="http://hsewx.com" target="_blank">国产精品成人啪精品视频免费</a>| <a href="http://lyaa17.com" target="_blank">国产亚洲视频在线播放</a>| <a href="http://508009.com" target="_blank">中文字幕a∨在线乱码免费看</a>| <a href="http://spxingyiquan.com" target="_blank">亚洲真人无码永久在线</a>| <a href="http://yuntao360.com" target="_blank">十八禁在线观看视频播放免费</a>| <a href="http://zhuanjiao521.com" target="_blank">中文字幕精品亚洲无线码一区</a>| <a href="http://yuyang0752.com" target="_blank">久久性生大片免费观看性</a>| <a href="http://426366.com" target="_blank">国产亚洲婷婷香蕉久久精品</a>| <a href="http://ybcin.com" target="_blank">亚洲一区免费观看</a>| <a href="http://hongyue8.com" target="_blank">亚洲网站在线播放</a>| <a href="http://www-5453.com" target="_blank">久久国内免费视频</a>| <a href="http://www-006688.com" target="_blank">亚洲国产精品18久久久久久</a>| <a href="http://trgod.com" target="_blank">亚洲毛片网址在线观看中文字幕 </a>| <a href="http://dxjz120.com" target="_blank">色欲色香天天天综合网站免费</a>| <a href="http://www-ttyx.com" target="_blank">久久久久亚洲av无码尤物</a>| <a href="http://vvv75.com" target="_blank">99久久久国产精品免费无卡顿</a>| <a href="http://ivy-fund.com" target="_blank">亚洲综合无码一区二区痴汉</a>| <a href="http://tjbdyx.com" target="_blank">国产在线观看www鲁啊鲁免费</a>| <a href="http://obtainfo.com" target="_blank">免费看一级毛片在线观看精品视频</a>| <a href="http://shzzhsy.com" target="_blank">亚洲综合无码精品一区二区三区</a>| <a href="http://51708695.com" target="_blank">99久久免费看国产精品</a>| <a href="http://cc45987.com" target="_blank">亚洲中文字幕久久久一区</a>| <a href="http://bjqhkf.com" target="_blank">亚洲精品无码久久久久AV麻豆</a>| <a href="http://142121.com" target="_blank">青青操视频在线免费观看</a>| <a href="http://6711wan.com" target="_blank">亚洲第一页在线播放</a>| <a href="http://kekead.com" target="_blank">国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 </a>| <a href="http://jiayila.com" target="_blank">色网站在线免费观看</a>| <a href="http://557265.com" target="_blank">亚洲AV无码专区在线播放中文</a>| <a href="http://020iws.com" target="_blank">一级女人18毛片免费</a>| <a href="http://wlzp88.com" target="_blank">美景之屋4在线未删减免费</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>