最近使用jetty + struts2 做了一个小项目,但是发现配置在welcome-file-list的默认首页失效了,访问项目的时候,一直报:There is no Action mapped for namespace / and action name . - [unknown location]异常,但是在访问的项目的地址后面加/index.jsp又可以正确访问,而且其他action也没有问题,就是
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>这个配置不起作用,不会自动跳转到index.jsp。在网上找了很久,很多解决方案都不行,但最终还是找到了,加入下面配置就可以了:
在struts配置中加入了default-action-ref成功解决这个问题:
<package name="home" namespace="/" extends="struts-default">
<default-action-ref name="index" />
<action name="index" >
<result name="success">/index.jsp</result>
</action>
</package>
本文详细介绍了使用Jetty+Struts2进行项目开发时,遇到默认首页配置失效的问题,并通过加入特定配置成功解决。重点强调了在struts配置中引入default-action-ref的重要性。
2065

被折叠的 条评论
为什么被折叠?



