通配符映射一:
a_add.action、b_add.action、c_add.action、全部请求PatternAction的add方法(请求同一个Action)
请求url
<a href="${pageContext.request.contextPath}/pattern/a_add.action">a_add</a><br> <a href="${pageContext.request.contextPath}/pattern/b_add.action">b_add</a><br> <a href="${pageContext.request.contextPath}/pattern/c_add.action">c_add</a><br>
struts-pattern.xml配置
<!-- <action name="*_add" class="com.struts2.action.pattern.PatternAction" method="add"> --> <!-- <result name="add">success.jsp</result> --> <!-- </action> -->
通配符映射二:
请求PeronAction和StudentAction的add方法(请求的不是同一个action)
请求的url为:
<a href="${pageContext.request.contextPath}/pattern/PersonAction_add.action">PersonAction</a><br> <a href="${pageContext.request.contextPath}/pattern/StudentAction_add.action">StudentAction</a><br>
struts-pattern.xml配置(1为第一个*的值)
<action name="*_add" class="com.struts2.action.pattern.{1}" method="add"> <result name="add">success.jsp</result> </action>
通配符映射三:
请求PatternAction中的aa、bb方法(同一个Action)
请求的url为:
<a href="${pageContext.request.contextPath}/pattern/patternAction_aa.action">patternAction_aa</a><br> <a href="${pageContext.request.contextPath}/pattern/patternAction_bb.action">patternAction_bb</a><br>
struts-pattern.xml中的配置为:
<action name="patternAction_*" class="com.struts2.action.pattern.PatternAction" method="{1}"> <result name="success">success.jsp</result> </action>
通配符映射四:
请求PersonAction和StudentAction中的aa、bb方法
请求的url为:
<a href="${pageContext.request.contextPath}/pattern/PersonAction_aa.action">PersonAction_aa.action</a><br> <a href="${pageContext.request.contextPath}/pattern/PersonAction_bb.action">PersonAction_bb.action</a><br> <a href="${pageContext.request.contextPath}/pattern/StudentAction_aa.action">StudentAction_aa.action</a><br> <a href="${pageContext.request.contextPath}/pattern/StudentAction_bb.action">StudentAction_bb.action</a><br>
struts-pattern.xml中配置为:
<action name="*_*" class="com.struts2.action.pattern.{1}" method="{2}"> <result name="success">success.jsp</result> </action>