热门文章 | 热门软件| 热门源码 | 热门电影 | 知识库 | 联系我们
软件 源码 教程 影视 健康 招聘
  HTML | JavaScript | ASP | PHP | JSP | NET | VB | VC | VF | Windows | Linux | Mysql | Mssql | Oracle | Struts 
当前位置: 创世纪计算机资源网 -> 文章频道 ->struts 
站内搜索:
struts小试牛刀之DispatchAction
作者:大灰狼 来源:创世纪计算机资源网 整理日期:2007-3-8

本文转载请标明出处:
作者:大灰狼
博客:http://www.gold98.net/blog
主页:http://www.gold98.net

今天小试了一下struts中的DispatchAction,现在来做个小小的总结:


首先们要将Action的继承关系改为:

public class User_hibernateAction extends DispatchAction {

下面就是各种方法的实现了:

public ActionForward AddUser(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {

public ActionForward updateUser(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {

.......

这里实现了以后,们还要修改配置文件:

<action attribute="user_hibernateForm"
        path="/hibernateAction"
        type="com.zb.struts.action.User_hibernateAction"
        parameter="method"
        name="user_hibernateForm"
        scope="request"
        input="/user_hibernate/userlist.jsp"
            >
<forward name="edit" path="/user_hibernate/edituser.jsp" />
<forward name="editok" path="/user_hibernate/userlist.jsp" />



基本跟原来的一样,只是添加了parameter,这个是必须的,上面已经用红色标记出来了;

接下来就是调用了~

在form的action中,们一般直接写配置文件中的path就Ok了,如上例:action="/hibernateAction"

但如果是在<a href中的话,这个path们就要稍作修改了:

假如你的web应用名称叫test,那么就应该写成: /test/hibernateAction.do

这个.do好像不能少,因为至少试的时候是这样的,这地方很容易被忽略,所以很容易出现找不到路径的错误~

如果们要调用添加用户的方法则写成:  /test/hibernateAction.do?method=AddUser

相关文章
暂无