我运行程序后报警告: Could not find action or result错误  但是我的action 和result 是存在的 
struts。xml中的配置
<action name="problemsAction" class="problemsAction"   method="add">
<result name="ok">/problems/ProblemsList.jsp</result>
<result name="error">/index.jsp</result>
</action>

<action name="problemsAction" class="problemsAction"  method="load">
<result name="success">/problems/AnswerQuestion.jsp</result>
<result name="error">/Login/Error.jsp</result>
</action>
 
javaaition中的代码
public String add() throws Exception {

System.out.println("fsdddddddddd");
System.out.println(problems.getTitle());
problems.setTitle(problems.getTitle());
problems.setCategory(problems.getCategory());
problems.setScore(problems.getScore());
problems.setContent(problems.getContent());
problemsDAOImpl.add(problems);
list = problemsDAOImpl.pageQuery(10,1);
return "ok"; public String load(int id) throws Exception { problems=problemsDAOImpl.loadById(id); return SUCCESS;
}
}
我再没有改成return "ok"前是对的  但是只是貌似是队的  他其实是使用了load方法的返回 
也就是 我在add()返回return SUCCESS; 时 在struts,xml中  他是调用的是<action name="problemsAction" class="problemsAction"  method="load">
<result name="success">/problems/AnswerQuestion.jsp</result>
<result name="error">/Login/Error.jsp</result>
</action>  我不知道为什么  我add方法是执行到的  在线等  先谢谢各位了

解决方案 »

  1.   

    problemsAction这个名字不能一样,分别起个不同的名字
      

  2.   

    action name="这个名字要唯一的"
      

  3.   

    哦   我请教一下这个name属性有什么意义    
      

  4.   

       JSP 可以使用action="problemsAction!add.action"  
      

  5.   

    访问这个action的时候,就是通过这个名字来访问的啊
      

  6.   

    我测试出来 只是还是有些不懂   JSP 可以使用action="problemsAction!add.action"    他的这个ACTION是怎么找到的  我的antion名字是Problems      
      

  7.   

    这个就跟你在编译java是一样的, 变量名重名编译能通过吗?你上面的问题  problemsAction!add.action这个是动态方法调用, 是定位到name为problemsAction以后执行这个action对应的class里面的add方法.!   !前面是actionName,后面是methodName
      

  8.   

    谢谢楼上的解答   是我对struts2的流程理解错误了   呵呵   我漏了一步   呵呵  造成的误区  
      

  9.   


       <action name="problemsAction" class="problemsAction"   method="add">
                <result name="ok">/problems/ProblemsList.jsp</result>
                <result name="error">/index.jsp</result>
            </action>
        
            <action name="problemsAction" class="problemsAction"  method="load">
                <result name="success">/problems/AnswerQuestion.jsp</result>
                <result name="error">/Login/Error.jsp</result>
            </action>
    名字不能相同 还有没有<result name="input">/Error.jsp</result>
      

  10.   

    呵呵  我在写的一个小项目 还在测试 我知道input 是默认 呵呵        谢谢大家的解答