南来的北往的,流布停车
<package name="default" namespace="/stu" extends="struts-default"><action name="stu_*" class="studentAction" method="{1}">
<interceptor-ref name="token">
<param name="includeMethods">add,update</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success">/stu_index.jsp</result>
<result name="update">/stu_update.jsp</result>
<result name="invalid.token" type="redirectAction">stu_index</result>
</action>
</package>
红色的竟然报错了
上面的颜色不懂是啥意思
Color --------------------编程问答-------------------- type="redirectAction"表示从一个action里跳入到另外一个action里面。 name="invalid.token"是防止重复提交的。
这个配置意思是如果重复提交,就跳到index方法内。 --------------------编程问答-------------------- 百度出来的,感觉解释的够详细了:
这里的{1}表示接收前面action里通过通配符传来的值,例如你配置的是<action name="*Crud" class="example.Crud" method="{1}"> ,然后调用***/editCrud.action,则method里获得的值是edit,将会调用这个action里面的 edit方法
附:
Action中的方法通配符
有些时候对Action中方法的调用满足一定的规律,例如edit Action对应edit方法,delete Action对应 delete方法,这个时候我们可以使用方法通配符,例如:
<action name="*Crud" class="example.Crud" method="{1}"> 这时,editCrud Action的引用将调用edit方法,同理,deleteCrud Action的引用将调用delete 方法。
另外一种比较常用的方式是使用下划线分割,例如:
<action name="Crud_*" class="example.Crud" method="{1}">
这样当遇到如下调用的时候可以找到对应的方法。
"action=Crud_input" => input方法
"action=Crud_delete" => delete方法
通配符和普通的配置具有相同的地位,可以结合使用框架的所有其他功能。
提问者评价
thank
参考资料:http://yjph83.blog.163.com/blog/static/551475792008520101617770/#
补充:Java , Java EE