You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by alley sys <sy...@hotmail.com> on 2008/10/04 17:27:35 UTC
ParameterAware Issue
Hi,
I am implemnting ParameterAware to get my request parameters:
I can see the request parameter is a String of Array([Ljava.lang.String;)
But I can't get the value out of it .
I used
String[] par = (String[])parameters.get("par");
System.out.println(par[0]);
but it doesn't show the value.
Can anyone assist ?
_________________________________________________________________
Re: ParameterAware Issue
Posted by Lukasz Lenart <lu...@googlemail.com>.
I've been trying to find some solution, but from my side, everything
looks ok, regarding API docs [1] all parameters are stored as a Array
of String in the Map, so you should be able to access it, could you
show your code?
[1] http://struts.apache.org/2.0.11.2/struts2-core/apidocs/org/apache/struts2/interceptor/ParameterAware.html
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: ParameterAware Issue
Posted by alley sys <sy...@hotmail.com>.
Struts 2.0.11
> Date: Sun, 5 Oct 2008 22:59:13 +0200> From: lukasz.lenart@googlemail.com> To: user@struts.apache.org> Subject: Re: ParameterAware Issue> > 2008/10/5 alley sys <sy...@hotmail.com>:> >> > hi,> > thanks for your quick reply. i checked the code> > it shows nothing.> >> > code:> > Object o = getParameters().get("partyid"); if (o instanceof String) { System.out.println("String = " + o); } else if (o instanceof String[]) { String[] a = (String[]) o; for(int i = 0; i < a.length; i++) { System.out.println("String partyid:"+a[i]); } }> >> > output:> > 17:20:08,643 INFO [STDOUT] String partyid:> > but the value is there> > partyid=[Ljava.lang.String;@38bbd7}> > i don't know why it doesn't shows ?> > It's something strange, it's mean that a[i] is array of String ([ -> array)> > Which Struts version?> > > Regards> -- > Lukasz> http://www.lenart.org.pl/> > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org>
_________________________________________________________________
Re: ParameterAware Issue
Posted by Lukasz Lenart <lu...@googlemail.com>.
2008/10/5 alley sys <sy...@hotmail.com>:
>
> hi,
> thanks for your quick reply. i checked the code
> it shows nothing.
>
> code:
> Object o = getParameters().get("partyid"); if (o instanceof String) { System.out.println("String = " + o); } else if (o instanceof String[]) { String[] a = (String[]) o; for(int i = 0; i < a.length; i++) { System.out.println("String partyid:"+a[i]); } }
>
> output:
> 17:20:08,643 INFO [STDOUT] String partyid:
> but the value is there
> partyid=[Ljava.lang.String;@38bbd7}
> i don't know why it doesn't shows ?
It's something strange, it's mean that a[i] is array of String ([ -> array)
Which Struts version?
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: ParameterAware Issue
Posted by alley sys <sy...@hotmail.com>.
hi,
thanks for your quick reply. i checked the code
it shows nothing.
code:
Object o = getParameters().get("partyid"); if (o instanceof String) { System.out.println("String = " + o); } else if (o instanceof String[]) { String[] a = (String[]) o; for(int i = 0; i < a.length; i++) { System.out.println("String partyid:"+a[i]); } }
output:
17:20:08,643 INFO [STDOUT] String partyid:
but the value is there
partyid=[Ljava.lang.String;@38bbd7}
i don't know why it doesn't shows ?
> Date: Sat, 4 Oct 2008 17:53:05 +0200> From: lukasz.lenart@googlemail.com> To: user@struts.apache.org> Subject: Re: ParameterAware Issue> > 2008/10/4 alley sys <sy...@hotmail.com>:> > thanks for your mail. yeah it shows 1 value is there having address> > but i need the value not address> > I'm not sure if I understood you, but if it shows 1, you should be> able to access it as a array, but if it's only one element, OGNL> shouldn't create an array, maybe try something like this> > Object o = parameters.get("par");> if (o instanceof String) {> System.out.println("String = " + o);> } else if (o instanceof String[]) {> String[] a = (String[]) o;> for(int i = 0; i < a.length; i++) {> System.out.println(a[i]);> }> }> > > Regards> -- > Lukasz> http://www.lenart.org.pl/> > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org>
_________________________________________________________________
Re: ParameterAware Issue
Posted by Lukasz Lenart <lu...@googlemail.com>.
2008/10/4 alley sys <sy...@hotmail.com>:
> thanks for your mail. yeah it shows 1 value is there having address
> but i need the value not address
I'm not sure if I understood you, but if it shows 1, you should be
able to access it as a array, but if it's only one element, OGNL
shouldn't create an array, maybe try something like this
Object o = parameters.get("par");
if (o instanceof String) {
System.out.println("String = " + o);
} else if (o instanceof String[]) {
String[] a = (String[]) o;
for(int i = 0; i < a.length; i++) {
System.out.println(a[i]);
}
}
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: ParameterAware Issue
Posted by alley sys <sy...@hotmail.com>.
Hi ,
thanks for your mail. yeah it shows 1 value is there having address
but i need the value not address.> Date: Sat, 4 Oct 2008 17:34:33 +0200> From: lukasz.lenart@googlemail.com> To: user@struts.apache.org> Subject: Re: ParameterAware Issue> > > String[] par = (String[])parameters.get("par");> > System.out.println(par[0]);> >> > but it doesn't show the value.> > Can anyone assist ?> > Try> System.out.println(par.length);> > > Regards> -- > Lukasz> http://www.lenart.org.pl/> > ---------------------------------------------------------------------> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For additional commands, e-mail: user-help@struts.apache.org>
_________________________________________________________________
Re: ParameterAware Issue
Posted by Lukasz Lenart <lu...@googlemail.com>.
> String[] par = (String[])parameters.get("par");
> System.out.println(par[0]);
>
> but it doesn't show the value.
> Can anyone assist ?
Try
System.out.println(par.length);
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org