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

问题描述

在struts2中,我利用了struts2中的内置OGNL,命名我的输入,如< input name ='bag [item]。property'>
哪个去了getter / setter 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参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 21:28