You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by peterv <pe...@earth-photography.com> on 2007/08/05 22:32:39 UTC
Linking to wildcard URLs
Hi,
Is there a way to make the <s:url> tag generate 'nice' URLs linking to
actions with wildcards in their names?
For example, let's take the following mapping using DefaultActionMapper:
<action name="galleries/*" method="execute" class="galleryViewer">
< param name="galleryID">{1}</ param>
<result>/pages/galleries/GalleryViewer.jsp</result>
</action>
With this mapping an HTTP request to http://server/galleries/3 invokes the
galleryViewer with the galleryID parameter set to 3. Unfortunately, when I
try to link to this action in a JSP using <s:url>, the URL generated by
Struts isn't the nice "/galleries/3", but the standard
"/galleries?galleryID=3" (which I'm trying to avoid). The JSP code:
<s:url action="galleries" id="url">
<s:param name="galleryID">3</s:param>
</s:url>
<s:a href="%{url}">View gallery 3</s:a>
How can I make Struts generate 'nice' URLs based on the <action> definitions
in struts.xml?
(Of course I could hardwire the custom URL format into each JSP that links
to the action, but that would be redundant and would take a lot of work to
change the URL structure later.)
Thanks,
Peter
--
View this message in context: http://www.nabble.com/Linking-to-wildcard-URLs-tf4221102.html#a12007966
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org