struts2.5 dynamic method invocation and default action

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.