struts2:This method: login for action user is not allowed!
来源:互联网 发布:淘宝上的nba旗舰店 编辑:程序博客网 时间:2024/06/06 03:10
本文转载:原文 http://blog.csdn.net/qq_29407009/article/details/51474118
-
struts2:This method: login for action user is not allowed!
在是用struts2 2.5版本的包的时候,出现一个很恶心的问题,就是使用动态方法的时候,报这样一个问题:This method: login for action user is not allowed!
出现这样一个原因是什么了?
点击这样报错的地方,进入源码查看源码,这是报错的地方的源码:
我们看到的是这个方法:if (config.isAllowedMethod(method)) { invocation.init(this);} else { throw new ConfigurationException("This method: " + method + " for action " + actionName + " is not allowed!");}
- 1
- 2
- 3
- 4
- 5
肯定是这个方法(config.isAllowedMethod(method))返回的是false,才回报错,进入这个方法,
看到这个方法的处理方法,method.equals(methodName != null ? methodName : DEFAULT_METHOD) || allowedMethods.isAllowed(method)”.其中这个是:DEFAULT_METHOD:execute
解释一下://1.methodName != null ? methodName : DEFAULT_METHOD 如果methodName 不等于空,就是返回methodName ,等于空就是DEFAULT_METHOD (execute)//2.method.equals()或allowedMethods.isAllowed(method),因为我们知道我们的处理方法是login,所以肯定是allowedMethods.isAllowed(method)这里出问题了!return method.equals(methodName != null ? methodName : DEFAULT_METHOD) || allowedMethods.isAllowed(method)
- 1
- 2
- 3
这是我断点看到的:
然后我们进入到allowedMethods.isAllowed(method)这个方法中//allowedMethods:这是集合是读取struts的配置文件得到的,但是我在使用2.5版本之前是没有的,我看断点调式的时候看到这个集合中的内容就是struts2包中struts-default.xml在最后面有这样一句话<global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods> public boolean isAllowed(String method) { for (AllowedMethod allowedMethod : allowedMethods) { if (allowedMethod.isAllowed(method)) { return true; } } return false; }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
看到这里我们大概就知道了解决方法了:
阅读全文
0 0
- struts2:This method: login for action user is not allowed!
- struts2:This method: login for action user is not allowed!
- Struts2-动态方法调用-Could not find action or result-Method update for action user is not allowed
- Struts2.5动态方法调用 错误Messages:This method: edit for action product is not allowed!解决方法
- Messages:This method: edit for action XXX is not allowed!-Struts2.5动态方法调用错误解决方法
- Method Not Allowed / The requested method POST is not allowed for the URL
- Host is not allowed to connect to this MySQL server 和 access denied for user 'root'@'localhost' 解决办法
- struts2 - There is no Action mapped for namespace [/login] and action name [login!loginInput] ...
- "This app is not allowed to query for scheme ***"
- Login failed for user 'username'. The user is not associated with a trusted SQL Server connection
- 彻底解决STRUTS2 错误There is no Action mapped for namespace / and action name login
- MyEclipse Struts2 There is no Action mapped for namespace [/] and action name [Login]
- IDEA配置Struts2出现There is no Action mapped for namespace [/] and action name [login]
- Host 'USER-20141212QO' is not allowed to connect to this MySQL server
- "Host 'USER-XXXX' is not allowed to connect to this MySQL server"
- codesign returns User Interaction is not allowed
- -canOpenURL: failed for URL: "wechat://" - error: "This app is not allowed to query for scheme wech
- -canOpenURL: failed for URL: "xx" - error:"This app is not allowed to query for scheme xx"
- java------多线程通信
- HTML--列表标签应用
- Java多线程学习总结(一)——多线程创建
- [Unity] Unity渲染优化
- window下C语言实现读取config.ini配置文件
- struts2:This method: login for action user is not allowed!
- 关于事件分发机制的思考
- 关于Boost
- Android性能优化之利用LeakCanary检测内存泄漏及解决办法
- 逻辑题1
- Python3学习笔记:迭代器与生成器
- oracle提示TNS:无监听程序的解决办法
- dos批处理 for用法
- 关于宿舍卫生打扫分配工作的程序