%{#request.contextPath}
doesn't work inside an s:a tag in Struts2. (Struts 2.2.1 to be specific.) Is there a way to make it work? It works in other Struts2 tags.
Here are two lines in a JSP file in a Struts 2 project whose context path is "/websites":
<s:a href="%{#request.contextPath}/clickme" theme="simple">Click here.</s:a>
<s:form method="post" action="%{#request.contextPath}/submitme" theme="simple"></s:form>
And here is the output:
<a href="/clickme">Click here.</a>
<form id="submitme" name="submitme" action="/websites/submitme" method="post"></form>
Notice that the context path is left off the anchor but is included in the form.
P.S. I can't use ${#pageContext.request.contextPath}
here because ${}
isn't allowed in Struts2 tags. Besides, I'm trying to be consistent. And I also try generally to avoid ${}
since it does not auto-escape the output.
Thanks!