目前使用的struts2的版本是2.5.10,教学视频上的版本是2.1.6。将代码改成动态调用时,出现There is no Action mapped for namespace [/user] and action name [user!add] associated with context path [/struts2_0219_ActionMethod]. - [unknown location]找不到action的问题。
查文档发现,要使用动态方法调用,必须设置Struts2允许动态方法调用,通过设置struts.enable.DynamicMethodInvocation常量来完成,该常量属性的默认值是true。
2.1.6版本默认值为true,而2.5.10版本的默认值为false
解决方案:使用最新的struts,需添加struts.properties文件,在其中添加struts.enable.DynamicMethodInvocation = true,
或者在struts.xml中添加