struts-DispatchAction

同一个Action 类来处理几个相关的任务。一个很好的例子是对一个数据记录执行基本的CRUD (创建读写修改删除)数据操作
public class book extends DispatchAction{
   public ActionForward Create(ActionMapping mapping,ActionForm form,HttpServletRequest Request,HttpServletResponse Response)
throws IOException,ServletException{
   .......
}
   public ActionForward read(ActionMapping mapping,ActionForm form,HttpServletRequest Request,HttpServletResponse Response)
throws IOException, ServletException{
   .......
}

   public ActionForward update(ActionMapping mapping,ActionForm form,HttpServletRequest Request,HttpServletResponse Response)
throws IOException, ServletException{
   .......
}

   public ActionForward delete(ActionMapping mapping,ActionForm form,HttpServletRequest Request,HttpServletResponse Response)
throws IOException, ServletException{
   .......
}

   //其他方法
}


在配置文件中:
  <action path="/book" type="app.recordDispatchAction" name="dataForm" scope="request" input="/index.jsp" parameter="method"/>

访问路径:
uri?method="方法名"

你可能感兴趣的:(struts,bbs)