使用Struts2感叹号方式的动态方法调用,struts.xml配置都正常,但是使用http://localhost:8080/XXX/user!list.action访问时,提示:
There is no Action mapped for namespace [/] and action name [user!list] associated with context path [XXX]
原因在于:struts2中默认不允许使用DMI。
此时需要修改struts.xml,添加:<constant name="struts.enable.DynamicMethodInvocation" value="true" /> ,设置这个常量值为true,就可以使用动态方法调用了。
事实上,这种方法是不推荐的,有另外两种动态方法调用的方法:
1.指定method属性
2.通配符方式(官网推荐使用)