• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
山高我为峰
博客园    首页    新随笔    联系   管理    订阅  订阅
在struts2.5版本中使用DMI遇到问题

struts2.5 为了提升安全性,添加了 allomethod 这么个玩意。

解决方法是在配置文件中添加:

   <package name="exam" extends="json-default">

        <global-allowed-methods>regex:.*</global-allowed-methods>

    <action name="user" class="userAction">
            ...
    </action>

    </package>

或者,针对action,在 action 块中添加

<allowed-methods>regex:.*</allowed-methods>

同样也支持在你的 action 上使用 @AllowedMethods 注解
默认的设置为

<global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>

全局设置是增量而不是覆盖的,支持正则和直接匹配方法

默认允许的allowedMethods范围

allowedMethods=[
LiteralAllowedMethod{allowedMethod='index'},
LiteralAllowedMethod{allowedMethod='input'},
LiteralAllowedMethod{allowedMethod='execute'},
LiteralAllowedMethod{allowedMethod='save'},
LiteralAllowedMethod{allowedMethod='browse'},
LiteralAllowedMethod{allowedMethod='delete'},
LiteralAllowedMethod{allowedMethod='back'},
LiteralAllowedMethod{allowedMethod='list'},
LiteralAllowedMethod{allowedMethod='cancel'}]

 

posted on 2017-07-11 17:28  山高我为峰  阅读(590)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3