随笔-40  评论-66  文章-0  trackbacks-0
 ActionErrors   errors   =   null;    
  errors   =   new   ActionErrors();    
  errors.add("isExist",   new   ActionError("error.isExist"));   
// errors.add("isExist",   new   ActionError("error.isExist"));   等效于errors.add("isExist",   new   ActionMessage("error.isExist"));    

  saveErrors(request,   errors);  
  return   (mapping.findForward("failure"));   


failure页面里也定义了<html:errors   name="isExist"/>  
  ApplicationResources.properties里面也定义了error.isExist=user   have   already   exist!!!   
  运行结果 跳转到failure页面,显示“user   have   already   exist!!!   ”




ActionErrors.GLOBAL_ERROR
怎么理解
它和我们使用普通的字符有什么区别啊

部分代码如下:
err.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.logon"));
err.add("errinfo", new ActionError("error.logon"));

以上两名有什么区别啊


没什么区别
ActionErrors.GLOBAL_ERROR也是一个字符串。
最好写做ActionErrors.GLOBAL_ERROR
不然的话可能会报错。


posted on 2006-12-20 18:03 Super·shen BLOG 阅读(2581) 评论(3)  编辑  收藏 所属分类: JAVA技术

评论:
# re: 关于ActionErrors add函数用法 2006-12-25 10:04 | shen
ActionMessage( )的构造函数参数个数 到底能有几个?  回复  更多评论
  
# re: 关于ActionErrors add函数用法[未登录] 2008-02-14 13:42 | 00
1213  回复  更多评论
  
# re: 关于ActionErrors add函数用法[未登录] 2010-03-15 15:19 | Haha
errors.add("isExist", new ActionError("error.isExist"));
参数isExist为null 或 “”(空字符串)都可以!前提是页面只有<html:errors />  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: