<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.0//en" "Http://struts.apache. Org/dtds/struts-2.3.dtd "><Struts>< Packagename= "Default"namespace="/"extends= "Struts-default"> <constantname= "Struts.enable.DynamicMethodInvocation"value= "true"></constant><!--specify the methods that can be used -<!--to reduce the definition of an action, you often define multiple methods in an action to respond to different requests, -<!--search for a method that specifies a method, based on a different situation, to find the result view corresponding to the return value -<!--1. Called by wildcard, _ represents the delimiter, * represents the match (the name value matching the result results) calls the Delete method, such as URL = "Localhost:8080/hellostruts2/delete_struts.action "<action name=" *_struts "class=" com.dunn.action.HelloStruts2 "method=" {1} "> <resul T >/result.jsp</result> <result name= "delete" >/{1}.jsp</result> <result na Me= "Hello" >/{1}.jsp</result> </action> - <!--2. Call by method name, specify the value of constant tag element struts.enable.DynamicMethodInvocation to True, call the Delete method, such as URL = "localhost:8080/ Hellostruts2/exestruts!delete.action "<action name=" exestruts "class=" Com.dunn.action.HelloStruts2 "> <result >/result.jsp</result> <result name= "Delete" >/delete.jsp</result> <result name= "Hello" >/hello.jsp</result> </action> - <!--3. By Action,name call, the URL of the call to the Delete method is, url= "localhost:8080/hellostruts2/deletestruts.action" <action name= " Hellostruts "class=" com.dunn.action.HelloStruts2 "method=" Hello "> <result >/result.jsp</result> </action> <action name= "deletestruts" class= "com.dunn.action.HelloStruts2" method= "Delete" > <result >/result.jsp</result> </action> - </ Package> </Struts>
View Code
Struts2---dynamic method invocation