struts-DispatchAction
程序员文章站
2022-05-08 18:05:36
...
同一个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="方法名"
上一篇: php 读取文件夹与文件夹中文件的函数
下一篇: PHP 画图应用 验证码 柱状图