struts2 no longer accepts http map parameters?

痞子三分冷 提交于 2019-12-19 07:53:21

问题


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.

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?


回答1:


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

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>

(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.

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



来源:https://stackoverflow.com/questions/4132573/struts2-no-longer-accepts-http-map-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!