Reputation: 4454
Using Struts2, I compute a link in my java code and expose the link's string in a getter for the JSP page. I try to link to this external link using <a href='<s:property value="mylink" />'>a Link</a>
. Sadly, Struts always puts the local context before this link, so the resulting link looks like <a href="http://localhost:8080/Mycontext/https://twitter.com/some?more=param&ete=rs">a Link</a>
.
Note: I also tried using <s:a>
and <s:url>
with includeContext="false"
... same result. What's wrong here?
Upvotes: 1
Views: 2750
Reputation: 75926
Struts always puts the local context before this link
uh? If you really write a plain <a ... >
element
<a href='<s:property value="mylink" />'>a Link</a>
in your jsp, then Struts2 will not add anything, Struts2 does not even know that there is a link there, the property
tag is just a general "echo the value of this property" instruction. You can check that by copying the same tag <s:property value="mylink" />
outside the A element. Either you are computing that property wrong in your action, or either you are not writing that jsp fragment but using some Struts2 tag related with links (<s:a>
or <s:url>
).
BTW, if you want to place an external link, unrelated to your application, the first option (a plain A element, not a Struts2 link tag) seems the right way.
Upvotes: 3