struts2版本 :2.5.8
1.<!--通配符设置打开 -->
<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>
2.通配符号是“*”,出现的地方在action name,后面出现的{1},代表通配符匹配到的字符
<action name="user_*" class="com.shop.user.action.UserAction" method="{1}">
3.之前并没有使用高版本的struts2,按照1,2两步走,没问题。
但是高版本会出现在package中找不到指定的action,是因为通配符未生效。
在csdn上看到前辈的笔记,struts2在2.3之前的版本,正常的配置就可以了,
但在之后的版本中,使用通配符调用方法时,内部会验证是否允许访问该方法。
添加属性:
<allowed-methods>允许访问的方法名,以“,”分隔</allowed-methods>
注意:DTD设置统一
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">