Struts2.5.10 版本为了安全考虑 默认是不允许DMI(动态方法访问)的
解决办法:
step1.
struts 标签下添加 <constant name="struts.enable.DynamicMethodInvocation" value="true"/> //允许DML
step2.
<a> action 标签下添加 <allowed-methods>regex:.*</allowed-methods> //允许DML指定action类方法
<b> package标签下添加 action <allowed-methods>regex:.*</allowed-methods> //允许DML所有action类方法:
<c> 如果想要设置指定方法
1. 给package标签设置 strict-method-invocation="true"
2.action 标签下添加 <allowed-methods>方法名</allowed-methods> //允许DML指定方法
<d> 设置action标签的method属性(默认为execute)
demo 如下
----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd">
<!-- START SNIPPET: xworkSample -->
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<package name="struts2" extends="struts-default">
<!--<global-allowed-methods>regex:.*</global-allowed-methods>-->
<action name="act1" class="Action.Act1">
<result name="page2">/page2.jsp</result>
<allowed-methods>regex:.*</allowed-methods>
</action>
</package>
</struts>