Am having a few issues with Struts2 related to URLs, was hoping someone could comment if these are bugs or expected behavior. They are:
1. I'd like to use the action attribute of the url tag to generate urls. I have a few different packages/namespaces set up and what I want to do is simply supply the full path (package + action) to the action like this: <@s.url action='/myNamespace/myAction'/> // I'm using Freemarker But that doesn't work. The link it builds is as such //myNamespace/myAction.action // Note the extra slash in front If I drop the slash in front, the generated link looks like this: myNamespace/myAction.action which is relative to the current path and not the application context as desired. So it doesn't work unless you're at the application root path. I realize that this is an option: <@s.url namespace='myNamespace' action='myAction'/> but I *really* don't want to use it - it's too verbose and it seems unnecessary to separate the namespace as a separate attribute. Plus I don't want the designer thinking about Struts namespaces, just url paths (I like to hide frameworky details wherever possible). Full paths to actions packages can be resolved when you go to a given url, why not in the s.url tag, too? I have resorted to this: <@s.url value='/myNamespace/myAction.action'/> I realize that it's not that much shorter than the namespace version, but keeping the path intact just seems much much better and easy to read to me. But I'd still like to avoid hard-coding the ".action" extension (so I can switch to a prettier Rails-style ActionMapper some day), so I'd prefer to use the action attribute over value. So my question is - is this a bug or am I trying to use the action attribute incorrectly? If that latter, why can't the full path be supported? 2. This is related. I'd like to have the following result for an action: <result type="redirect-action">/myNamespace/myAction</result> but this doesn't work for (presumably) the same reason. The redirect goes to //myNamespace/myAction.action // Extra slash up front I could drop the slash, but get the same problem mentioned above about the url no longer being relative to the application root. Sure, I can get around the problem with this: <result type="redirect-action"> <param name="namespace">/myNamepsace</param> <param name="actionName">myAction</param> </result> But - ooof. XML hell. I just want to specify a simple path and don't want all the clutter. Is there another way? 3. I tried to use the submit tag to create an image that can submit a form like so: <@s.submit type="image" src="/images/searchButton.jpg"/> But this does not produce a url relative to the application root. I can't nest a url tag to create the url, so is there a way to do this? (I'm guessing I can add some ognl scripting to call some struts util for building the url, but I hate to have hacks like that in a simple tag.) Thanks for your help. -- View this message in context: http://www.nabble.com/generating-urls-with-namespaces-tf2782624.html#a7763784 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]