ActionMessages errors = new ActionMessages();
errors.add("errorMsg",new ActionMessage("form.errors.notnull"));
saveErrors(request,errors);说明:
  1、errorMsg 就是一个变量名
  2、form.errors.notnull 你理解的对是到资源文件去找的属性名
  将form.errors.notnull的值保存在errorMsg变量里面,然后可以在页面
配合<html:error />使用,
  例如:<html:errors property="errorMsg"/>,明白了吧。

解决方案 »

  1.   

    恩,ActionMessages的问题明白了。但ActiomMessage的问题还没解答。
    2。ActionMessage(String key, Object value)
    后面那个value有什么用?
      

  2.   

    2。ActionMessage(String key, Object value)
    后面那个value有什么用?----
    后面的value是boolean,true/false;
    true--default,表示使用MessageResource.properties;
    false--表示不使用MessageResource.properties,此时,key值就是value值.
      

  3.   

    楼上回答不对啊。
    我做了测试。
    修改前的例子是:
    ApplicationResource.properties里有句
    hello.dont.talk.to.monster=We don't want to say hello to Monster!!!
    某个Action里有句:
    errors.add("username", new ActionMessage("hello.dont.talk.to.monster", badUserName ));
    结果页面可以把We don't want to say hello to Monster!!!显示出来。然后我把ApplicationResource.properties里的
    hello.dont.talk.to.monster=We don't want to say hello to Monster!!!
    删了。
    把Actiom里的改成errors.add("username", new ActionMessage("hello.dont.talk.to.monster", false ));
    按你说的应该页面显示hello.dont.talk.to.monster
    但是却没有任何显示。ps:我一开始就觉得不对劲,第二个参数如果是boolean的话,为何sun要写成Object?