先上关键代码:
struts.xml文件内容:    <package name="default" namespace="/" extends="struts-default">        <action name="index" class="actionclass.contral">
            <result name="myindex">
/myindex.jsp
            </result>
         
        </action>
    </package>contral.java文件内容:package actionclass;public class contral {

public String execute(){
return "myindex";
}
}问题:我本意是访问http://localhost:8080/study0809/index,然后找到index所在action,然后调用我自己写的类actionclass.contral,然后返回myindex字符串,然后根据result配置的节点,然后跳转到myindex.jsp.但是我访问的时候页面无法跳转到myindex.jsp,而是跳转到其他页面了

解决方案 »

  1.   

    LZ代码貌似没错,其他页面名字是啥,搜搜配置文件。看看对应的result。
    检查result是否为myindex.jsp会不会有拦截器啥的改变了result。
      

  2.   

    web.xml中,有个welcome-file-list的节点,lz去看看
      

  3.   

    跳转到了默认页面,也就是web.xml文件中的<welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>,跳转到了index.jsp页面
      

  4.   

    故意写错的配置看看?比如action名,然后重启tomcat
      

  5.   

    既然是跳转到其他页面了,
    public String execute(){
    return "myindex";
    }那么就是这个没有执行啊。你要是直接访问:http://localhost:8080/study0809/index.jsp或者是直接访问:http://localhost:8080/study0809/他都会自动显示web.xml中那个index.jsp页面。你要是访问:http://localhost:8080/study0809/index.action那么就会去寻找index.action。从而执行actionclass.contral里面的execute方法啊。
      

  6.   


    还有就是 execute()方法的返回值 默认的是 “success”。 LZ 如果你改了相应的配置的话,那么就应该没什么问题了。你……
      

  7.   

    楼上的回答都不对!
    struts action要这样配置才行:<!-- 转到你的页 -->
     <result name="myindex" type="redirectAction">myindex.jsp</result>
      

  8.   

    现在 CSDN 越来越堕落了.............
      

  9.   

    详细 可以参考这篇
    http://wanggp.iteye.com/blog/663701
      

  10.   

    没必要填type,默认的就行了吧
      

  11.   

    10楼的 type根本不用填,默认的就是dispatcher !!
      

  12.   

    打断点看看吧,看有没进入你的action方法。没有的话就看看配置是不是那里配错了。
      

  13.   

    问题解决了,我把myeclipse关了,然后重新打开,然后就一切就正常了,应该是BUG,讨厌BUG