TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
ERROR:
java.lang.ClassCastException: org.apache.struts.action.ActionMessage
ActionErrors 和 ActionError两个类,不用ActionMessages 和 ActionMessage两个类,就可以了.
ActionErrors errors = new ActionErrors();
String userName = (String)((HelloForm) form).getUserName();
String badUserName = "Monster";
if (userName.equalsIgnoreCase(badUserName)) {
errors.add("username", new ActionError("hello.dont.talk.to.monster", badUserName));
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}
和
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if ((userName == null) || (userName.length() < 1))
errors.add("username", new ActionError("hello.no.username.error"));
return errors;
} |
|