%{#request.contextPath}doesn't work inside 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 the JSP file in the 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 conclusion:
<a href="/clickme">Click here.</a>
<form id="submitme" name="submitme" action="/websites/submitme" method="post"></form>
Please note that the context path is left unbound, but is included in the form.
PS I canβt use it ${#pageContext.request.contextPath}here because itβs ${}not allowed in Struts2 tags. In addition, I try to be consistent. And I also try to avoid it altogether ${}, as it does not automatically delete the output.
Thank!
source
share