Hi Wes, Thanks for taking time to answer my question. Guess I was not clear with the the examples I gave. Yes, I am using all Struts actions, s:url, s:a tags, and everything. The thing is the Struts tags:
<s:url var="theLink" action="world" namespace="/whatever" *encode="true"*> <s:param name=country value="whatever"/> <s:param name="city" value="whatever"/> </s:url> <s:a href="#theLink">nyc</s:a> don't seem to implicitly call "response.encodeURL" as the c:url tag would if I used plain JSP and JSTL. As a result, UrlRewritter cannot intercept it and apply the outbound rules. I was wondering if there were ways to get around that. Cheers, Daniel On Thu, Mar 12, 2009 at 11:44 PM, Wes Wannemacher <w...@wantii.com> wrote: > On Thursday 12 March 2009 23:34:22 Daniel Ruan wrote: >> Has anyone used the UrlRewriter outbound rules with Struts 2? >> UrlRewriter requires that the urls go through response.encodeURL(). >> In JSP and JSTL examples: >> >> <a href="<%= response.encodeURL("/world.jsp?country=usa&city=nyc") >> %>">nyc</a> >> >> <a href="<c:url value="/world.jsp?country=${country}&city=${city}" >> />">nyc</a> >> >> What is the Struts2 equivalent way? (s:url encode="true" does not work). >> >> Thanks, >> > > I'm not sure if I'm answering your question, but the struts2 way would differ > slightly from your example in two ways - > > 1. world.jsp should be converted to an action rather than a JSP. You could > simple map world.jsp to ActionSupport if you didn't want to code a whole > action, but since your taking parameters, I would suggest writing an action > for it. > > 2. Rather than using a scriptlet, you'd use the struts2 tags to generate the > link. This could be done in a few ways - > > 2a. generate the url with the s:url tag and assign it to a variable on the > value stack to use with the s:a tag - > <s:url var="theLink" action="world" namespace="/whatever"><s:param > name=country value="whatever"/><s:param name="city" value="whatever"/></s:url> > <s:a href="#theLink">nyc</s:a> > > 2b. use the s:url tag right in the href= of your HTML a tag - > <a href="<s:url action="world" namespace="/whatever"><s:param ... > > 2c. If possible, use the recently committed (today) version of s:a - > <s:a action="world" namespace="/whatever"><s:param ... > > Again, I'm not sure if I'm answering your question, but I know one of the > reasons I use Struts is to avoid adding scriptlets. > > -Wes > > -- > > Wes Wannemacher > Author - Struts 2 In Practice > Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more > http://www.manning.com/wannemacher > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >