struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Nenning <Christoph.Nenn...@lex-com.net>
Subject Re: URL Array parameter encoding arr[]=1&arr[]=2&arr[]=3
Date Fri, 22 May 2015 07:21:32 GMT
> 
> Using S2 2.3.16.3
> 
> My action wants to take an array of parameters, if they are passed like
> arr=1&arr=2&arr=3 then everything works fine.
> 
> But by default JQuery encodes arrays as URL parameters like
> arr[]=1&arr[]=2&arr[]=3,
> the parameters get named "arr[]" instead of "arr".
> 
> My action has a setter like:
> 
> public void setArr(String[] arr)
> 
> This isn't matching the parameter "arr[]" so the setter never gets 
called.
> 
> Is there a way to have Struts recognize that parameters "arr[]" is the 
same
> as array "arr"?
> 
> If not, how do I construct a setting that will accept parameters named
> "arr[]"?
> 
> 
> Greg
> 
> P.S. I know how to force jQuery to encode the "traditional" way but 
would
> be nice it just worked.




You can play with ParameterNameAware, not sure if that would work.
Otherwise you could implement an own interceptor which sets those 
parameters on your action.


Regards,
Christoph

This Email was scanned by Sophos Anti Virus

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message