You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stephen Turner <st...@MIT.EDU> on 2010/08/06 22:48:06 UTC

s:url tag - multiple params with same name

Hello all,

I'd like to format a URL with multiple parameters having the same name, eg:

   ?pn=firstval&pn=secondval&pn=thirdval

Is this possible using <s:url> ? I've tried this:

<s:url...>
    <param name="pn" value="firstval" />
    <param name="pn" value="secondval" />
    <param name="pn" value="thirdval" />
</s:url>

This doesn't work - I get:

   ?pn=thirdval

Doing something similar with the JSTL <c:url> tag does work, but I'd like  
to stick with the struts tag if possible.

Thanks,
Steve

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


Re: Re : s:url tag - multiple params with same name

Posted by Dave Newton <da...@gmail.com>.
Well, the OP said it did in the post you replied to, so I bet you're right!

On Wed, Aug 11, 2010 at 8:11 PM, Zoran Avtarovski
<zo...@sparecreative.com>wrote:

> I haven¹t tried it but I suspect that if you use a list it should work.
>
> Something like this:
> <s:url id="xurl" value="a.b" includeParams="get" escapeAmp="false">
>      <s:param name="pn" value="'#{Œfirstval¹,¹secondVal¹,¹thirdVal¹}'" />
> </s:url>
>
>
> Z.
>
> >
> > On Fri, 06 Aug 2010 17:12:10 -0400, François Rouxel <ro...@yahoo.com>
> > wrote:
> >
> >> > should be working, did you put in s:url tag includeParameters='get' ?
> >> >
> >
> > Yes, although I don't think that's what includeParams is used for -
> here's
> > my actual code:
> >
> > <s:url id="xurl" value="a.b" includeParams="get" escapeAmp="false">
> >      <s:param name="pn" value="'firstval'" />
> >      <s:param name="pn" value="'secondval'" />
> >      <s:param name="pn" value="'thirdval'" />
> > </s:url>
> >
> > URL 1: <s:property value="xurl"/>
> >
> >
> > and here's the result:
> >
> > URL 1: a.b?pn=thirdval
> >
> > I'm using Struts 2.0.11
> >
> > Steve
>
>

Re: Re : s:url tag - multiple params with same name

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
I haven¹t tried it but I suspect that if you use a list it should work.

Something like this:
<s:url id="xurl" value="a.b" includeParams="get" escapeAmp="false">
     <s:param name="pn" value="'#{Œfirstval¹,¹secondVal¹,¹thirdVal¹}'" />
</s:url>


Z.

> 
> On Fri, 06 Aug 2010 17:12:10 -0400, François Rouxel <ro...@yahoo.com>
> wrote:
> 
>> > should be working, did you put in s:url tag includeParameters='get' ?
>> >
> 
> Yes, although I don't think that's what includeParams is used for - here's
> my actual code:
> 
> <s:url id="xurl" value="a.b" includeParams="get" escapeAmp="false">
>      <s:param name="pn" value="'firstval'" />
>      <s:param name="pn" value="'secondval'" />
>      <s:param name="pn" value="'thirdval'" />
> </s:url>
> 
> URL 1: <s:property value="xurl"/>
> 
> 
> and here's the result:
> 
> URL 1: a.b?pn=thirdval
> 
> I'm using Struts 2.0.11
> 
> Steve


Re: Re : s:url tag - multiple params with same name

Posted by Stephen Turner <st...@MIT.EDU>.
On Fri, 06 Aug 2010 17:12:10 -0400, François Rouxel <ro...@yahoo.com>  
wrote:

> should be working, did you put in s:url tag includeParameters='get' ?
>

Yes, although I don't think that's what includeParams is used for - here's  
my actual code:

<s:url id="xurl" value="a.b" includeParams="get" escapeAmp="false">
     <s:param name="pn" value="'firstval'" />
     <s:param name="pn" value="'secondval'" />
     <s:param name="pn" value="'thirdval'" />
</s:url>

URL 1: <s:property value="xurl"/>


and here's the result:

URL 1: a.b?pn=thirdval

I'm using Struts 2.0.11

Steve

-- 
Stephen Turner
Senior Programmer/Analyst - MIT IS&T

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


Re : s:url tag - multiple params with same name

Posted by François Rouxel <ro...@yahoo.com>.
should be working, did you put in s:url tag includeParameters='get' ?

 ____________________________________________ 
____________________________________________



----- Message d'origine ----
De : Stephen Turner <st...@MIT.EDU>
À : user@struts.apache.org
Envoyé le : Ven 6 août 2010, 16h 48min 06s
Objet : s:url tag - multiple params with same name


Hello all,

I'd like to format a URL with multiple parameters having the same name, eg:

  ?pn=firstval&pn=secondval&pn=thirdval

Is this possible using <s:url> ? I've tried this:

<s:url...>
   <param name="pn" value="firstval" />
   <param name="pn" value="secondval" />
   <param name="pn" value="thirdval" />
</s:url>

This doesn't work - I get:

  ?pn=thirdval

Doing something similar with the JSTL <c:url> tag does work, but I'd like to 
stick with the struts tag if possible.

Thanks,
Steve

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


      

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


Re: s:url tag - multiple params with same name

Posted by Stephen Turner <st...@MIT.EDU>.
On Fri, 06 Aug 2010 20:49:03 -0400, Martin Gainty <mg...@hotmail.com>  
wrote:

>
> <s:url>
> <!-- assume your Action contains a collection -->
> <!--   public java.util.ArrayList<CartItem> availableItems;  -->
>  <s:iterator value="availableItems">
> <!-- each CartItem has a name, Price and OriginalValue attributes -->
> <td><s:property value="name" /></td>
> <td><s:property value="Price" /></td>
> <td><s:property value="OriginalValue" /></td>
> </tr>
> </s:iterator>
> </s:url>
>
> if the action collection accessor formats the array to deliver each  
> attribute of CartItem as expected by param within url
> then grab the array from the action..
> <s:url>
> <s:param name="pn" value="%{'action.availableItems'}" />
> </s:url>
>
> Martin Gainty

Mr Gainty wins the prize.

For reference, this works:

<s:url id="xurl" value="a.b" includeParams="none" escapeAmp="false">
     <s:param name="pn" value="{'firstval','secondval','thirdval'}" />
</s:url>

URL 1: <s:property value="xurl"/>

Result is:

URL 1: a.b?pn=firstval&pn=secondval&pn=thirdval

which is what I was looking for.

Steve

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