struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: <s:url.../> tag and hiding parameters in the link
Date Tue, 08 Jan 2008 22:32:29 GMT
Zuquirio is correct, you can't do it. See comments inline below:

lei.java@gmail.com wrote:
> Definitely I'll post it to let everyone get benefit if I figure it out.
> 
> By the way, welcome everybody to give suggestion.
> 
> Thanks.
> 
> On Jan 7, 2008 1:33 PM, zuquirio <zuquirio@gmail.com> wrote:
> 
>> I'm not an expert but I don't think you can do it. But, if you do so,
>> please
>> post it. Thanks.
>>
>> lei.java@gmail.com wrote:
>>> Hi all,
>>>
>>> I use <s:url.../> tag to create a link to an action and <s:param.../>
>> tag
>>> to
>>> pass one variable "lang", like this:
>>>
>>> <s:url id="editUrl" namespace="/ssicsi" action="edit">
>>>  <s:param name="lang" value="fr"/>
>>> </s:url>
>>>
>>> I don't want the "lang=fr" to appear in the URL so I tried to do it by

You can't create a link that passes data without using request 
parameters. Links always generate GET requests, and request parameters 
are how GET requests pass data to the server.

>>> including
>>>  <s:param name="method" value="post"/>

That would just add a request parameter name 'method' to the URL for the 
GET request.

>>> in the <s:url.../> body or setting includeParams="none" in the <url>
tag
>>> like this
>>>  <s:url id="editUrl" namespace="/ssicsi" action="edit"
>>> includeParams="none">
>>>   ...
>>>  </s:url>
>>> but neither works. I use struts 2.0.11.

You can create a URL without the 'lang' request parameter, simply by not 
specifying it. But then, as noted, you have no other (direct) way of 
passing that data with a link.

You have three options:

1) just accept then presence of the query string in the URL; it's a 
standard HTTP thing

2) use a form instead of a link, in which case you can set the method to 
POST instead of GET. You can make the form's submit button *look* like a 
regular link again using CSS.

3) store the information in a cookie when the page with the link is 
requested. The cookie will be passed back with each subsequent request 
(both GETs and POSTs).

Without better understanding your requirements, that's the most advice I 
can offer but hopefully it'll give you some options to experiment with.

L.


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


Mime
View raw message