You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Seaborn <Ma...@performgroup.com> on 2008/02/14 11:12:25 UTC

ParametersInterceptor setting values using a String[]

This appears to have been mentioned a number of times in the Struts 2
and XWork forums but I cannot find a real answer:

 

Using Struts 2.0.11 I am experiencing the following problem. 

I have an action with the method 

setId(Integer id) { ... } 

When this value is set via a HTTP request through the
ParametersInterceptor it succeeds when using both GET and POST. However
when a GET is performed I get the following exception logged 

SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception
caught setting 'id' on 'class com.opensymphony.xwork2.ActionSupport:
Error setting expression 'id' with value '[Ljava.lang.String;@1a1f635' 

XWork appears to store the a single GET parameters as an array of
Strings and attempt to set the value using the String[] first, when that
errors tries to convert it. The problem with this is it logs the first
failure as an ERROR. 

Why is this happening and short of creating my own TypeConverter or
blocking it in the logger config, how can I stop this error being logged
for GET requests?

 

 

 





 


Matthew Seaborn

Software Architect
t    +44(0) 208 484 0729
m  +44(0) 7949 465 142

e   matthew.seaborn@performgroup.com
<ma...@performgroup.com> 

 
Sussex House
Plane Tree Crescent
Feltham, Middlesex, TW13 7HE
United Kingdom
http://www.performgroup.com/ <http://www.performgroup.com/>  

 

 


________________________________________________________________________

CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system.

SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence.

VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient�s responsibility to ensure that email is virus free.

AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group.

COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278.

Re: ParametersInterceptor setting values using a String[]

Posted by je...@blueskyminds.com.au.
Hi Matthew,

The params interceptor is calling setId on ActionSupport (the default
action), not on your action that has the setId method, so an exception is
being thrown as there's no matching setter whatsoever.  You may have a
config error.

All params are treated as arrays because its valid in HTTP for the same
parameter to be specified multiple times in the same request.

The default type conversion will call setId(Integer id) using the first
element in the array if that's the first property to be matched.

The error is only logged when the exception occurs and this is
*infrequent* in normal use.

Hope that helps!

regards,
Jeromy Evans

> This appears to have been mentioned a number of times in the Struts 2
> and XWork forums but I cannot find a real answer:
>
>
>
> Using Struts 2.0.11 I am experiencing the following problem.
>
> I have an action with the method
>
> setId(Integer id) { ... }
>
> When this value is set via a HTTP request through the
> ParametersInterceptor it succeeds when using both GET and POST. However
> when a GET is performed I get the following exception logged
>
> SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception
> caught setting 'id' on 'class com.opensymphony.xwork2.ActionSupport:
> Error setting expression 'id' with value '[Ljava.lang.String;@1a1f635'
>
> XWork appears to store the a single GET parameters as an array of
> Strings and attempt to set the value using the String[] first, when that
> errors tries to convert it. The problem with this is it logs the first
> failure as an ERROR.
>
> Why is this happening and short of creating my own TypeConverter or
> blocking it in the logger config, how can I stop this error being logged
> for GET requests?
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Matthew Seaborn
>
> Software Architect
> t    +44(0) 208 484 0729
> m  +44(0) 7949 465 142
>
> e   matthew.seaborn@performgroup.com
> <ma...@performgroup.com>
>
>
> Sussex House
> Plane Tree Crescent
> Feltham, Middlesex, TW13 7HE
> United Kingdom
> http://www.performgroup.com/ <http://www.performgroup.com/>
>
>
>
>
>
>
> ________________________________________________________________________
>
> CONFIDENTIALITY - This email and any files transmitted with it, are
> confidential, may be legally privileged and are intended solely for the
> use of the individual or entity to whom they are addressed. If this has
> come to you in error, you must not copy, distribute, disclose or use any
> of the information it contains. Please notify the sender immediately and
> delete them from your system.
>
> SECURITY - Please be aware that communication by email, by its very
> nature, is not 100% secure and by communicating with Perform Group by
> email you consent to us monitoring and reading any such correspondence.
>
> VIRUSES - Although this email message has been scanned for the presence of
> computer viruses, the sender accepts no liability for any damage sustained
> as a result of a computer virus and it is the recipient’s responsibility
> to ensure that email is virus free.
>
> AUTHORITY - Any views or opinions expressed in this email are solely those
> of the sender and do not necessarily represent those of Perform Group.
>
> COPYRIGHT - Copyright of this email and any attachments belongs to Perform
> Group, Companies House Registration number 6324278.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: ParametersInterceptor setting values using a String[]

Posted by Daniel Baldes <db...@open.ch>.
Matthew Seaborn wrote:
> Why is this happening and short of creating my own TypeConverter or 
> blocking it in the logger config, how can I stop this error being logged 
> for GET requests?

AFAIK this error is only logged in devMode.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org