开发者

struts2 no longer accepts http map parameters?

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开发者_JS百科 do I get my map-parameters back?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜