熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Struts 1.2.2 新功能全新體驗

2022-06-13   來源: Java開源技術 

  () orgapachestrutsactionAction的改動
  
  在Action類中增加了addMessagesaddErrorsgetErrorsgetMessages四個方法
  便於處理ActionMessages和ActionErrors
  
  
  I protected void addMessages(
   HttpServletRequest request
   ActionMessages messages)
  
  II protected void addErrors(
   HttpServletRequest request
   ActionErrors errors)
  
  III protected ActionErrors getErrors(HttpServletRequest request)
  
  IV protected ActionMessages getMessages(HttpServletRequest request)
  
  下面的代碼片斷是關於ActionMessages的(ActionErrors的例子類似):
  
  ActionMessages messages=getMessages(request);
  //xxxxxx代表Resource Bundle中的Key值
  ActionMessage msg=new ActionMessage(xxxxxx);
  messagesadd(ActionMessagesGLOBAL_MESSAGEmsg);
  addMessages(requestmessages);
  
  //在中不必調用saveMessages將ActionMessages對象保存到request
  //因為在addMessages中已經包含了此功能
  //具體可參見Struts 的Action源代碼
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28544.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.