隨筆-26  評(píng)論-44  文章-20  trackbacks-0
          在struts的表單bean的validate()方法中:
          if(username.trim().equals(""))
                      error.add("username", new ActionMessage("error.username.username_is_requred"));
          if(password.trim().equals(""))
                      error.add("password", new ActionError("error.password.password_is_requred"));
          測(cè)試后,兩個(gè)的效果看起來一樣。
          我初次嘗試這些,看不出它們的不同。
          那位高手有興趣的,請(qǐng)多多指教!
          posted on 2007-08-06 22:57 開機(jī) 閱讀(1422) 評(píng)論(2)  編輯  收藏 所屬分類: struts

          評(píng)論:
          # re: ActionError和ActionMessage有什么區(qū)別? 2007-09-04 22:16 | Tiger F
          能夠?qū)崿F(xiàn)的功能基本一樣,主要是語義的區(qū)別,message用于做一些提示和確認(rèn)的文字,error則是錯(cuò)誤提示。struts標(biāo)簽?zāi)J(rèn)情況下也會(huì)使用不同的html標(biāo)記和格式顯示它們。  回復(fù)  更多評(píng)論
            
          # re: ActionError和ActionMessage有什么區(qū)別? 2007-10-11 09:37 | wind in midnight
          我也是在重寫formbean的validate()時(shí)
          ActionErrors errors
          errors.add( ActionErrors.GLOBAL_MESSAGE,new ActionError("error.name.required"));
          在error.jsp中<html:errors/>能接受倒錯(cuò)誤信息
          如果是ActionMessage 就報(bào)cast class exception
            回復(fù)  更多評(píng)論
            

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 南京市| 河源市| 迁安市| 荆州市| 芜湖市| 宜州市| 唐海县| 富裕县| 陕西省| 定西市| 东丽区| 瑞安市| 江陵县| 黄石市| 汕头市| 汕尾市| 济阳县| 高青县| 莆田市| 福贡县| 雅江县| 大理市| 钟祥市| 洪泽县| 平安县| 获嘉县| 建平县| 塔城市| 英吉沙县| 马尔康县| 汶上县| 和硕县| 汉源县| 板桥市| 长沙县| 嵩明县| 神池县| 长垣县| 中方县| 永川市| 绥德县|