Messages:This method: edit for action XXX is not allowed!-Struts2.5动态方法调用错误解决方法
来源:互联网 发布:无线虚能矩阵 编辑:程序博客网 时间:2024/06/03 22:42
struts.xml部分配置
Action部分代码
报错信息
解决方案
此处查阅了大量文章,还有struts官方文档:
- struts2:This method: login for action user is not allowed!
- 在struts2.5版本中使用DMI遇到问题
- Struts 2.5 动态方法调用(DMI)问题
- Apache Struts 2 Documentation Action Configuration
解决方法无非是在配置文件中添加
<global-allowed-methods>regex:.*</global-allowed-methods>
例如我的struts.xml中配置:
<package name="yong" extends="struts-default"> <!-- 配置自定义拦截器LoginedCheckInterceptor --> <interceptors> <interceptor name="loginedCheck" class="com.yong.struts.interceptor.LoginedCheckInterceptor" /> </interceptors> <!--struts2.5之后要添加此属性才能访问action,方法名以逗号隔开,或使用正则匹配--> <global-allowed-methods>regex:.*</global-allowed-methods></package>
或者,针对action,在 action 块中添加
<allowed-methods>regex:.*</allowed-methods>
同样,也支持在你的 action 上使用 @AllowedMethods
注解
struts-default默认的设置为
<global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>
全局设置是增量而不是覆盖的,支持正则和直接匹配方法,
源码在这两段
// com.opensymphony.xwork2.DefaultActionProxy#prepare// com.opensymphony.xwork2.config.entities.ActionConfig#isAllowedMethod
但是经过这样的配置之后总是不生效,经过排查发现在action中使用了@ParentPackage(value = "struts-default")
注解,这样的话只支持struts-default默认的方法通过。将这里改为:
@ParentPackage(value = "yong")
value为你自定义package的名称,继承自struts-default。这样便可使上述的配置生效。
吐槽:struts2真是大坑,每次因为爆出安全漏洞而升级版本都会出现各种问题。
阅读全文
0 0
- Messages:This method: edit for action XXX is not allowed!-Struts2.5动态方法调用错误解决方法
- Struts2.5动态方法调用 错误Messages:This method: edit for action product is not allowed!解决方法
- Struts2-动态方法调用-Could not find action or result-Method update for action user is not allowed
- struts2:This method: login for action user is not allowed!
- struts2:This method: login for action user is not allowed!
- Struts2中DMI(动态方法调用)的错误问题(There is no Action mapped for namespace [/xxx] and action name [xxx!yyy] a)
- this class is not key value coding-compliant for the key XXX错误的解决方法
- this class is not key value coding-compliant for the key XXX错误的解决方法
- Host 'XXX' is not allowed to connect to this MySQL server 解决方法/开启MySQL远程账号
- 服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server如何解决
- 服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server
- 服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server
- 服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server
- 解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
- 解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
- 解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
- 服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server
- 解决报错:错误1130- Host xxx is not allowed to connect to this MariaDb server
- Servlet处理流程分析
- C#学习笔记
- [bzoj5042][ST表]LWD的分科岛
- A SQLiteConnection object for database '/data/user/0/com.google.android.gms/
- 列表渲染
- Messages:This method: edit for action XXX is not allowed!-Struts2.5动态方法调用错误解决方法
- 【deeplearning.ai】第二门课:提升深层神经网络——偏差和方差
- 【51Nod1952】栈
- dubbo入门官方案例学习
- springmvc上传图片方法
- Android Webview H5交互之LocalStorage
- C++数据结构: 线性表之单链表
- 缓存淘汰算法 LFU and LRU
- 进程同步与异步