action标签中method={1}怎么理解

其实用到method={数字}的时候,相应的前面的action是要出现*通配符来搭配的。比如一个小例子:
<action name="user_*" class="UserAction" method="{1}">
在对应的jsp中:
<form action="user_userLogin2" method="post">
那么struts会将user_userLogin2这个action按照user_*的格式解析,把*号对应位置的字符串取出来,放到method={}这个中括号里替代数字的位置,1就是指第一个*号位置的字符串。
这里看不出数字不同的区别,在:
<action name="*_*" class="com.xy.{1}Action" method="{2}">
中就看得明白了,你提交的action都会按格式分解,比如jsp里是User_add,那么就会变成:
class="com.xy.UserAction" method="{add}"

posted @ 2017-04-05 20:25  KylinStayHere  阅读(821)  评论(0编辑  收藏  举报