最近使用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>