我的action也继承了DispatchAction
  也配置了 parameter="command",带参数无法后却无法使用里面的方法,直接过
   我一直都那样写 ,今天新写个项目就出现这个问题
   大家帮帮忙

解决方案 »

  1.   

    在用DispatchAction的时候别忘记了在STRUTS-CONFIG中的<action>属性加parameter="method"
    还有<html:form>和普通的<form>是有区别的,在用form提交表单的时候别忘记要加范围method="post",不然也会有错
    另外在action.do/method=XXXX这个中间不要有空格楼主仔细检查检查看看
      

  2.   

      
       1.<action>属性加了parameter="method" 
       2.我是用<form>也加了method="post"
       3.action.do/method=XXXX这个中间没有空格
    真的很奇怪
      

  3.   


    “直接过”是什么意思?
    看看参数值和方法名是否对应上了
    再不行设断点看看行不行,如果设断点也没有反应,不进方法里,有可能是ActionForm里的验证方法有判空条件。
      

  4.   


    那就真的很奇怪了,你清空下tomcat安装目录(如果不是安装版,找根目录;另外有需要tomcat安装版的朋友可以去我的资源里看看)下的work文件夹,webapps文件夹下的该项目也删除掉
    重新用tomcat部署该项目,然后重启tomcat看看
    应该没什么问题
      

  5.   

        我的DispatchAction  有save、find这些方法,当我save完转到跳转到find就直接进入input指向的页面,如果我先find在跳转其他也相同
        如果我带的参数值在DispatchAction  没有的话应该指向unspecified这个方法,可是也直接来input指向的页面
       好像这action类就是个普通的action,只能用一次一样
        我直接用a标签访问 也input指向的页面
      

  6.   

     我用strutsTest 测试不管带什么参数都不会执行这个action类
     也没有任务异常
      

  7.   

    你说你是先进到save方法后又跳转到find方法,那么你的跳转必须是重定向的,要不就会到input页面
      

  8.   

    <forward name="find" path="/user.do?method=find" redirect="true"></forward>
      

  9.   

      就是重定向的啊
      strutsTest测试不管带什么参数都不会执行里面任务一个方法
      

  10.   

    1.actionpublic class QuestionAction extends DispatchAction {
    @Override
    protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("-----------questionAction.unspecified()-----------");
        ActionForward  af=new ActionForward("addQuestion2.do?command=findAll&pageNo=1",true);
    return  af;
    }

    private QuestionServer quesServer;
    private Question question;
    private Item item;
    public void setItem(Item item) {
    this.item = item;
    }
    public void setQuesServer(QuestionServer quesServer) {
    this.quesServer = quesServer;
    }
    public void setQuestion(Question question) {
    this.question = question;
    }
    public ActionForward add(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("-----add------");
    return null;
    }

    public ActionForward save(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    QuestionActionForm qaf=(QuestionActionForm)form;
    BeanUtils.copyProperties(question, qaf);
    Set itemSet=new HashSet<Item>(0);
    for(String str: qaf.getItemName()){
    Item item=new Item();
    item.setItemName(str);
    item.setResult(0);
    item.setQuestion(question);
    itemSet.add(item);
    }
    question.setItem(itemSet);
    quesServer.save(question);
    ActionForward af=new ActionForward("addQuestion2.do?command=findAll&pageNo=1",true);
    return af;
    }

    public ActionForward findAll(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    QuestionActionForm qaf=(QuestionActionForm)form;
    int pageNo=qaf.getPageNo();
    PageModel pageModel=quesServer.findAll(pageNo);
    request.setAttribute("pageModel", pageModel);
    return mapping.findForward("listQuestion");
    }
    }
      

  11.   

    public class QuestionAction extends DispatchAction {
    @Override
    protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("-----------questionAction.unspecified()-----------");
        ActionForward  af=new ActionForward("addQuestion2.do?command=findAll&pageNo=1",true);
    return  af;
    }

    private QuestionServer quesServer;
    private Question question;
    private Item item;
    public void setItem(Item item) {
    this.item = item;
    }
    public void setQuesServer(QuestionServer quesServer) {
    this.quesServer = quesServer;
    }
    public void setQuestion(Question question) {
    this.question = question;
    }
    public ActionForward add(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    System.out.println("-----add------");
    return null;
    }

    public ActionForward save(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    QuestionActionForm qaf=(QuestionActionForm)form;
    BeanUtils.copyProperties(question, qaf);
    Set itemSet=new HashSet<Item>(0);
    for(String str: qaf.getItemName()){
    Item item=new Item();
    item.setItemName(str);
    item.setResult(0);
    item.setQuestion(question);
    itemSet.add(item);
    }
    question.setItem(itemSet);
    quesServer.save(question);
    ActionForward af=new ActionForward("addQuestion2.do?command=findAll&pageNo=1",true);
    return af;
    }

    public ActionForward findAll(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    QuestionActionForm qaf=(QuestionActionForm)form;
    int pageNo=qaf.getPageNo();
    PageModel pageModel=quesServer.findAll(pageNo);
    request.setAttribute("pageModel", pageModel);
    return mapping.findForward("listQuestion");
    }
      

  12.   

    不好意思卡了下 发了两次
    <action path="/Question/addQuestion2" 
    name="quseForm"
    input="/Question/addQuestion2.jsp" 
     scope="request"
     parameter="command">
    <forward name="listQuestion"path="/Question/listQuestions.jsp" />
    </action>
      

  13.   

      ActionForward  af=new ActionForward("/addQuestion2.do?command=findAll&pageNo=1",true); 你这是不是少写了一个/阿
      

  14.   

    new ActionForward("addQuestion2.do?command=findAll&pageNo=1",true); 你这个后面的true是表示重定向吗,我很少用这个一般都是配置到struts中去的
      

  15.   

    要不你把转向配置到struts中看看行不
      

  16.   

      恩  添加true表示重定向
      

  17.   

    我在strutsTest中,应该是会执行unspecified。这个能在struts里配置?
    public void testQuestion(){
    this.addRequestParameter("pageNo", "1");
    this.addRequestParameter("command", "aa");
    this.setRequestPathInfo("/Question/addQuestion2.do");
    this.actionPerform();
    }
      

  18.   

    unspecified方法是当你没有command参数时候调用的方法撒,不需要配置吧
      

  19.   

    谢谢各位的回答
    问题终于解决的了
    验证框架出了问题,所以没有都往input跳
    呵呵 人感冒晕乎乎的