struts2.5动态方法绑定问题
来源:互联网 发布:剑三重置版优化补丁 编辑:程序博客网 时间:2024/06/14 16:32
Struts动态方法绑定不成功,Struts2.5动态方法调用失败升级问题
今天发现Struts2.5版本的不能使用动态方法绑定 查了下说是调用实体类action时不安全,新版本中默认关闭了
在Struts.xml中配置了开启还是不能使用
文件如下
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <!-- <constant name="struts.enable.DynamicMethodInvocation" value="true" /> --> <constant name="struts.objectFactory" value="spring"></constant> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package name="default" extends="struts-default" namespace="/"> <action name="hello" class="com.maobo.action.LoginAction"> <result name="ok">/WEB-INF/page/success.jsp</result> <result name="error">/WEB-INF/page/error.jsp</result> </action> <action name="hi" class="com.maobo.action.LoginAction" method="hi"> <result name="ok">/WEB-INF/page/success.jsp</result> <result name="error">/WEB-INF/page/error.jsp</result> </action> <action name="m_*" class="com.maobo.action.LoginAction" method="{1}"> <result name="ok">/WEB-INF/page/success.jsp</result> <result name="error">/WEB-INF/page/error.jsp</result> </action> </package> </struts>
执行
http://127.0.0.1/MVS/m_hi 返回
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [m_hi] associated with context path [/MVS].
MVS WEB项目工程名
不知为何? 开关已经打开了的
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
参考资料:
http://blog.csdn.net/achilles12345/article/details/37697457
http://zhidao.baidu.com/link?url=Og-hTpiYl1pUGRnZEy6F9ijXFxC9quYNdg-jLKe9l9BMBeM2yh6wVexZwHggIcumLe4I8RgFl2f9ZgU2DVp0ps29xZAL4OKyQH8ns2t1NkW
这篇里说action里加 *
加上后配置文件泛红报错
官方配置文件
http://struts.apache.org/docs/action-configuration.html
http://www.brucephillips.name/blog/index.cfm/2011/2/19/Struts-2-Security-Vulnerability–Dynamic-Method-Invocation
http://blog.csdn.net/javaalpha/article/details/8855368
此篇文章说通配符要把属性设为false ???
这篇算是解决了问题
http://ask.csdn.net/questions/260958
总结一下
2.5版本是要打开开关不错。配置文件之所以报错的原因是因为头信息中版本号不对!复制了官方的头信息后泛红报错的地方会消失。
完整配置文件如下
官方参考
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"><struts> <constant name="struts.objectFactory" value="spring"></constant> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <package name="default" extends="struts-default" namespace="/"> <!-- 关键地方 struts2.5 为了提升安全性,添加了 allomethod 这么个玩意--> <global-allowed-methods>regex:.*</global-allowed-methods> <action name="login*" class="com.maobo.action.LoginAction" method="{1}"> <result name="ok">/WEB-INF/page/success.jsp</result> <result name="error">/WEB-INF/page/error.jsp</result> </action> </package></struts>
注意头部信息中
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"><struts>
版本号应为 struts-2.5.dtd
关键地方 struts2.5 为了提升安全性,添加了 allomethod 这么个玩意
<global-allowed-methods>regex:.*</global-allowed-methods>
具体请参考文章不再细述
http://ask.csdn.net/questions/260958
- struts2.5动态方法绑定问题
- struts2.5动态方法绑定问题
- [Struts2 框架学习] Struts2.5 通配符动态方法调用问题
- struts2.5动态方法调用不能使用问题
- Struts2 动态方法调用小问题
- struts2动态方法调用 无效问题
- struts2 动态访问Action方法NoSuchMethodException问题
- Struts2使用!动态方法调用无效问题
- Struts2动态方法调用(DMI)小问题
- Java 方法 动态绑定
- 动态绑定方法
- 动态绑定方法 MethodType()
- dataTables-动态绑定问题
- dataTables-动态绑定问题
- jquery on方法 绑定动态元素 出现的问题
- [JavaScript] jquery on方法 绑定动态元素 出现的问题
- 多态&动态绑定&方法匹配&方法绑定
- JavaEE struts2.5的动态方法调用
- javascript 面试题收集
- Hadoop Archives 小数据处理
- 内联函数总结
- 简单工厂模式(Factory)
- Seekbar使用
- struts2.5动态方法绑定问题
- 中山培训第三题(未解决)
- NWU CCCC选拔赛 1014阶乘问题(思维题)
- java.lang.NoClassDefFoundError: org/activiti/bpmn/model/StartEvent
- HBase学习之三: hbase filter(过滤器)和coprocessor(协处理器)统计行数的简单应用
- SyntaxError: Non-UTF-8 code starting with
- CTF 【每日一题 20160707】凯撒加密
- arcgis的破解安装
- CNN 卷积神经网络结构