使用defaultAction配置默认action
<default-action-ref name="index" />
<action name="index">
<result type="redirectAction">User_add</result>
</action>
使用这种配置可以在用户输入错误的url跳转至User_add.action,但是如果你输入的url只到工程名,即../webApp/
那这时候默认action是不会起作用的。
1、在web.xml中定义了欢迎界面,它会跳转到welcome页面!
2、如果在web.xml中没有配置欢迎界面,会自动跳转至webRoot下面的index页面!
3、如果上面两种情况都没有,即既没有在web.xml中配置,webRoot下面也没有index页面,那这样struts中的默认action就会起作用了!