关键字 :struts 路径通配符使用
一、struts2通配符的使用
<struts>
<package name="sshweb" extends="struts-default" namespace="/common">
<action name="*_*" class="{1}" method="{2}" >
<result>/pages/{1}.jsp</result>
<result name="input" >/jsp/{1}.jsp</result>
<result name="C0101001" type="redirectAction">C0101001_execute</result>
<result name="C0101002" type="redirectAction">C0101002_execute</result>
<result name="C0101003" type="redirectAction">C0101003_execute</result>
<result name="C0101004" type="redirectAction">C0101004_execute</result>
<result name="C0101005" type="redirectAction">C0101005_execute</result>
</action>
</package>
</struts>
说明:路径/TestAction_getMessage请求会交给 TestAction类的 getMessage方法去处理
或
<package name="user" extends="struts-default" namespace="/">
<action name="user_*" class="com.test.action.UserAction" method="{1}">
<result>/user_{1}.jsp</result>
</action>
</package>
说明:路径user_zhaoshijie 请求会交给zhaoshijie方法去处理
二、struts1通配符使用
<struts-config>
<action-mappings>
<action path="/test/TestAction_*" type="com.test.action.TestAction" parameter="{1}TestAction">
<forward name="add" path="/test/addTest.jsp" />
</action>
</action-mappings>
</struts-config>
说明:路径/test/TestAction_zhaoshijie 请求会交给 zhaoshijieTestAction方法去处理
或
<action
path="/Edit*"
type="com.oreilly.strutsckbk.ch07.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<forward
name="success"
path="/edit_{1}.jsp"/>
</action>
<action
path="/Save*"
type="com.oreilly.strutsckbk.ch07.Save{1}Action"
name="{1}Form"
scope="request"
validate="true"
input="edit_{1}.jsp">
<forward
name="success"
path="/saved_{1}.jsp"/>
</action>
一、struts2通配符的使用
<struts>
<package name="sshweb" extends="struts-default" namespace="/common">
<action name="*_*" class="{1}" method="{2}" >
<result>/pages/{1}.jsp</result>
<result name="input" >/jsp/{1}.jsp</result>
<result name="C0101001" type="redirectAction">C0101001_execute</result>
<result name="C0101002" type="redirectAction">C0101002_execute</result>
<result name="C0101003" type="redirectAction">C0101003_execute</result>
<result name="C0101004" type="redirectAction">C0101004_execute</result>
<result name="C0101005" type="redirectAction">C0101005_execute</result>
</action>
</package>
</struts>
说明:路径/TestAction_getMessage请求会交给 TestAction类的 getMessage方法去处理
或
<package name="user" extends="struts-default" namespace="/">
<action name="user_*" class="com.test.action.UserAction" method="{1}">
<result>/user_{1}.jsp</result>
</action>
</package>
说明:路径user_zhaoshijie 请求会交给zhaoshijie方法去处理
二、struts1通配符使用
<struts-config>
<action-mappings>
<action path="/test/TestAction_*" type="com.test.action.TestAction" parameter="{1}TestAction">
<forward name="add" path="/test/addTest.jsp" />
</action>
</action-mappings>
</struts-config>
说明:路径/test/TestAction_zhaoshijie 请求会交给 zhaoshijieTestAction方法去处理
或
<action
path="/Edit*"
type="com.oreilly.strutsckbk.ch07.Edit{1}Action"
name="{1}Form"
scope="request"
validate="false">
<forward
name="success"
path="/edit_{1}.jsp"/>
</action>
<action
path="/Save*"
type="com.oreilly.strutsckbk.ch07.Save{1}Action"
name="{1}Form"
scope="request"
validate="true"
input="edit_{1}.jsp">
<forward
name="success"
path="/saved_{1}.jsp"/>
</action>