Struts.xml:
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.3//en" "http://struts.apache.org/dtds/ Struts-2.3.dtd "><struts><!--override Struts2 Some constants default value--<constant name=" Struts.enable.DynamicMethodInvocation "value=" false "/> <constant name=" Struts.devmode "value=" true "/> < ; constant Name= "struts.action.extension" value= "Action,,do" ></constant> <constant name= " Struts.configuration.xml.reload "value=" true "></constant><package name=" Default "namespace="/hello/ xxx "extends=" Struts-default "><action name=" Test1 "><result>/index.jsp</result></action ></package><package name= "P1" extends= "Struts-default" ><action name= "test2" class= " Com.opensymphony.xwork2.ActionSupport "method=" execute "><result name=" Success "type=" Dispatcher ">/ Index.jsp</result></action><action name= "test3" class= "com.itheima.actions.ActionDemo1 "method=" dosomething "><result>/index.jsp</result></action><!--<action Name= "Testadd" class= "Com.itheima.actions.ActionDemo1" method= "Addmethod" ><result>/index.jsp</result ></action><action name= "Testupdate" class= "Com.itheima.actions.ActionDemo1" method= "UpdateMethod" > <result>/index.jsp</result></action>-<!--action Method wildcard--<!--convention is better than the configuration path:/http Localhost:8080/day24_03struts2_constant/customeraction_addcustomer.action Action class: Customeraction action method: AddCustomer Results turned to page: addcustomer.jsp--><action name= "*_*" class= "Com.itheima.actions". {1} "method=" {2} "><result>/{2}.jsp</result></action></package></struts>
Note Line tenth, value= "Action,,do" in the middle of the two comma, so that the configuration can be accessed at the time of the path to omit the later. Action
Customeraction.java:
Package Com.itheima.actions;import Com.opensymphony.xwork2.actionsupport;public Class Customeraction extends Actionsupport{public String Addcustomer () {System.out.println ("Addcustomer"); return SUCCESS;} Public String Delcustomer () {System.out.println ("Delcustomer"); return SUCCESS;} Public String UpdateCustomer () {System.out.println ("UpdateCustomer"); return SUCCESS;}}
Struts2 Action Method wildcard character