In the dynamic method call, the use of wildcard method problems, referring to http://www.cnblogs.com/jasonlixuetao/p/5933671.html this blog, the problem solved.
This is helloworld.xml:
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.5//en"4 "Http://struts.apache.org/dtds/struts-2.5.dtd">5 6 <Struts>7 < Packagename= "Default"namespace="/"extends= "Struts-default">8 <Global-allowed-methods>regex:.*</Global-allowed-methods>9 <Actionname="*_*_*"Method= "{2}" Ten class= "Com.imooc." {3}. {1} Action "> One <result>/result.jsp</result> A <resultname= "Add">/{2}.jsp</result> - <resultname= "Update">/{2}.jsp</result> - </Action> the </ Package> - </Struts>
This file is included in the Struts.xml:
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.5//en"4 "Http://struts.apache.org/dtds/struts-2.5.dtd">5 6 <Struts>7 8 <includefile= "Helloworld.xml"></include>9 <constantname= "Struts.enable.DynamicMethodInvocation"value= "false"></constant>Ten One </Struts>
The dynamic method call to resolve the 2.5 version wildcard is added with this sentence:
< Global-allowed-methods >regex:.*</global-allowed-methods>
However, the problem comes, when using the default action, plus this sentence will be error, do not add to normal operation, the following is the normal operation of the Helloworld.xml:
1 <?XML version= "1.0" encoding= "UTF-8"?>2 <!DOCTYPE Struts public3 "-//apache software foundation//dtd Struts Configuration 2.5//en"4 "Http://struts.apache.org/dtds/struts-2.5.dtd">5 6 <Struts>7 < Packagename= "Default"namespace="/"extends= "Struts-default">8 9 <Default-action-refname= "Index"></Default-action-ref>Ten <Actionname= "Index"> One <result>/error.jsp</result> A </Action> - - <Actionname="*_*_*"Method= "{2}" the class= "Com.imooc." {3}. {1} Action "> - <result>/result.jsp</result> - <resultname= "Add">/{2}.jsp</result> - <resultname= "Update">/{2}.jsp</result> + </Action> - </ Package> + </Struts>
Also found that only the default action can be run, and cannot be called to the Add or Update method.
struts2.5 dynamic method invocation and default action