struts action

来源:互联网 发布:模拟电网软件 编辑:程序博客网 时间:2024/05/16 06:04

action 有两个:form , action

 

form:

public class BeerSelectForm extends ActionForm { // actionform is struts-class

  public ActionErrors validate(ActionMapping mapping , HttpServletRequest request){

    ActionErrors errors = new ...;

    errors.add("color",new ActionError("color not valid");

    return errors;

  }

}

 

action:

public class BeerSelectAction extends Action{

  public ActionForward execute(ActionMapping mapping,ActionForm form,

                                              HttpServletRequest request, ... response){

    ...

    return mapping.findForward("operation"); // operation is a forward-name in 'struts-config.xml'

  }

}

原创粉丝点击