Struts config<action
      attribute="friendlinkgroupForm"
      input="/manager/friendlinkgroup_list.jsp"
      name="friendlinkgroupForm"
      path="/friendlinkgroup"
      scope="request"
      type="com.scccms.friendlinkgroup.web.FriendlinkgroupAction">
      <forward
        name="myedit"
        path="/manager/friendlinkgroup_edit.jsp"
        redirect="true" />
Action...
else if (act.equalsIgnoreCase("new")) {
   myForm.setId(0);
   myForm.setTitle("");
   return mapping.findForward("myedit");
}
...
return new ActionForward(mapping.getInput());现在的问题是在 /friendlinkgroup.do 的页面中,我提交act=new后应该跳转到 manager/friendlinkgroup_edit.jsp
实际上是,页面执行do后到 manager/friendlinkgroup_list.jsp页面请问下是什么原因,为什么没有执行 return mapping.findForward("myedit");
或者说我应该怎么做

解决方案 »

  1.   

    Action没有接收到new.没有执行那个循环.你是在做编辑功能吧..有没有跳错.DO阿? 好好检查下吧,
      

  2.   

    首先查看下act的值是否得到或者是否正确,为什么没有act.equalsIgnoreCase("new")) 
    根据楼主的描述这段程序返回了
    return new ActionForward(mapping.getInput());
      

  3.   


    String act = myForm.getActionType();

    if(act==null){
    act=Constants.FORM_ACTION_INIT;
    }
    System.out.println(act); if (Constants.FORM_ACTION_LIST.equalsIgnoreCase(act)|| act.equalsIgnoreCase(Constants.FORM_ACTION_INIT)) {
    try {
    if (act.equalsIgnoreCase(Constants.FORM_ACTION_INIT)) {
    myForm.setCurrentPageNo(1);
    }
    int CurrentPageNo = myForm.getCurrentPageNo();
    setList(myForm, CurrentPageNo);
    } catch (BaseException e) {
    e.printStackTrace();
    }
    else if (Constants.FORM_ACTION_NEW.equalsIgnoreCase(act)) {
    //新建
    myForm.setId(0);
    myForm.setTitle("");
    System.out.println("1111111111111");
    return mapping.findForward("myedit");
    } else if (Constants.FORM_ACTION_EDIT.equalsIgnoreCase(act)) {
    //编辑初期
    try {
    myDao.QueryData(myForm, myForm.getId());
    } catch (BaseException e) {
    e.printStackTrace();
    }
    return mapping.findForward("myedit");
    } else if (Constants.FORM_ACTION_SAVE.equalsIgnoreCase(act)) {
    //保存
    int c_id=myForm.getId();
    String c_title=myForm.getTitle();
    try {
    if (myForm.getId() > 0) {
    myDao.updateData(myForm, c_id);
    } else {
    myDao.insertData(myForm);
    }
    } catch (BaseException e) {
    e.printStackTrace();
    }
    return mapping.findForward("list");
    } else if (Constants.FORM_ACTION_REFER.equalsIgnoreCase(act)) {
    //参照
    try {
    myDao.QueryData(myForm, myForm.getId());
    } catch (BaseException e) {
    e.printStackTrace();
    }
    return mapping.findForward("Refer");
    } else if (Constants.FORM_ACTION_DELETE.equalsIgnoreCase(act)) {
    myForm.setActionType(Constants.FORM_ACTION_LIST);
    //删除
    String[] selected = myForm.getSelected();
    try {
    if (selected == null) {
    } else {
    for (int i = 0; i < selected.length; i++) {
    myDao.deleteData(java.lang.Integer.parseInt(selected[i]));
    }
    }
    int CurrentPageNo = myForm.getCurrentPageNo();
    setList(myForm, CurrentPageNo);
    } catch (BaseException e) {
    e.printStackTrace();
    }第一次运行/friendlinkgroup.do ,页面是正常的,显示列表页
    print结果是init
    然后我点击新建提交这个form
    print结果new,11111111111
    说明act有值的,那个判断也是进入的,可就是不到edit页面,还是回到list页面
      

  4.   

    你调试下你的程序是否走到else if (act.equalsIgnoreCase("new"))这一步,但从你这几行代码看没什么问题,肯定是你在其它地方写错了,导致程序无法正常运行的。
      

  5.   

     return mapping.findForward("myedit");
    [color=#FF0000]?程序中的这个是什么意思?
      

  6.   

    查看是不是调用的这个else if里的逻辑?