Struts2 three ways of dynamic invocation

Dynamic invocation is to solve a process corresponding to a plurality of requests Action

1, specifies the method attribute

<action name="save" method="save" class="com.struts.HelloWorldAction">
<result>/save.jsp</result>
</action>

2, exclamation way

Be sure to remember to add

<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
<action name="helloworld" class="com.struts.action.HelloWorldAction">
<result>/reuslt.jsp</result>
<result name="save">/save.jsp</result>
</action>

3, wildcards way

name is returned in the result value of the call Action, Action's Action name of the method is a method, it is the last target input {1} _ {2} .action a method is invoked; Action, a plurality of such access methods

<action name="*_*" method="{2}" class="com.struts.action.{1}Action">
<result>/result.jsp</result>
<result name="save">/{2}.jsp</result>
<result name="delete">/{2}.jsp</result>
</action>

  

Guess you like

Origin www.cnblogs.com/tttty/p/11417682.html