(-) org.apache.struts.action.Action的改动.
在Action类中增加了addMessages、addErrors、getErrors、getMessages四个方法
便于处理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);
//xx.xx.xx代表Resource Bundle中的Key值.
ActionMessage msg=new ActionMessage("xx.xx.xx");
messages.add(ActionMessages.GLOBAL_MESSAGE,msg);
addMessages(request,messages);
//在1.2.2中不必调用saveMessages将ActionMessages对象保存到request.
//因为,在addMessages中已经包含了此功能.
//具体可参见Struts 1.2.2的Action源代码.
查看本文来源