....则在Struts 1.2中可以这么撰写就好了:
<action
path="/editProfile"
type="onlyfun.caterpillar.EditProfileAction"
name="profileForm"
scope="request"
validate="false">
<forward
name="failure"
path="/mainMenu.jsp"/>
<forward
name="success"
path="/profile.jsp"/>
</action>
<action
path="/editDocument"
type="onlyfun.caterpillar.EditDocumentAction"
name="documentForm"
scope="request"
validate="false">
<forward
name="failure"
path="/mainMenu.jsp"/>
<forward
name="success"
path="/document.jsp"/>
</action>
....
....如上设定,如果是edit开头的请求,就会与通配字符比对,并将除去前缀部份字符串作为查找Action的依据,例如 /editProfile.do就会查找EditProfileAction的action设定,而/editDocument.do就会查找 EditDocumentAction的action设定。
<action
path="/edit*"
type="onlyfun.caterpillar.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<forward
name="failure"
path="/mainMenu.jsp"/>
<forward
name="success"
path="/{1}.jsp"/>
</action>
....
* | 比对一个或多个字符,不包括斜线 ('/') 字符 |
** | 比对一个或多个字符,包括斜线 ('/') 字符 |
\character | 反斜线字符被用于跳脱字符,所以 \* 会用于比对星号 ('*'),而 \\ 比对反斜线 ('\'). |