struts2 不再接受http map 参数? [英] struts2 no longer accepts http map parameters?

查看:29
本文介绍了struts2 不再接受http map 参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 struts2 中,我利用了 struts2 中内置的 OGNL,将输入命名为 <input name='bag["item"].property'>哪个去 getters/setters getBag().get("item").setProperty(value)我已经升级到 struts 2.2.1,突然那些不再工作:getter 永远不会被调用.

In struts2, I took advantage of built-in OGNL in struts2, naming my inputs like <input name='bag["item"].property'> Which went to getters/setters getBag().get("item").setProperty(value) I've upgraded to struts 2.2.1, and suddently those no longer work: the getter never gets called.

互联网对在参数中使用 OGNL 完全保持沉默,好像从来没有人制作过复杂的表格.

The internet is utterly silent on using OGNL in parameters, as if nobody ever made complex forms.

如何取回我的地图参数?

How do I get my map-parameters back?

推荐答案

事实证明,他们加强了对参数名称的限制以提高安全性.

It turns out that they hardened restrictions on parameter names to boost security.

所以我不得不添加到我的 struts.xml:

So I had to add to my struts.xml:

       <interceptor-stack name="defaultStack">
          <interceptor-ref name="params">
             <!-- For maps to work -->
             <param name="acceptParamNames">
                 [a-zA-Z0-9.][()_'s"/]+
             </param>
          </interceptor-ref>
       </interceptor-stack>

(我的参数名称中有s 和/s")在那之后文件上传停止工作(拦截器堆栈很疯狂),所以我也必须明确添加它.

(I had "s and /s in my parameter names) File upload ceased working after that (interceptor stacks are madness), so I had to add it explicity either.

更新:最近我强烈建议使用 JSON 来传递复杂的结构,而不是丰富的 OGNL 形式.当然你需要一些 JS.

Update: These days I strongly suggest using JSON to pass complex structures instead of rich OGNL forms. Of course you would need some JS.

这篇关于struts2 不再接受http map 参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆