How to configure s:url to return the absolute path, so that it doesn't get affected by html base?

StackOverflow https://stackoverflow.com/questions/22314777

Question

Using <base href="<s:url value="/"/>" target="_blank"> resolves all images & stylesheets properly, when there are many namespaces like /, /admin etc.

But the action urls also get interrupted by base tag.

Suppose the current browser url is http://context/admin/dashboard

<s:url value="clients" namespace="admin"/> returns clients which in the browser gets resolved to http://context/clients instead of http://context/admin/clients

Is there a way to tell s:url to render absolute URLs instead of relative ?

http://struts.apache.org/development/2.x/docs/url.html

Était-ce utile?

La solution

You have wrong value to the tag attribute namespace. The namespace value should correspond to the package attribute and use the path value calculated from the web content root. So, if you have declared the namespace="/admin" this value should be used to the corresponding url tag attribute.

<s:url action="clients" namespace="/admin"/> 

The result outputs to HTML, and you could see what value is rendered.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top