更新时间:2023-01-07 12:51:21
这应该有效:
<s:set id="contextPath" value="#request.get('javax.servlet.forward.context_path')" />
<s:a href="%{contextPath}/clickme" theme="simple">Click here.</s:a>
但是,您不应该这样做.需要网址时,请使用<s:url>
标记:
However, you're not supposed to do this. When you need an url, use the <s:url>
tag:
<%-- Without specifying an action --%>
<s:url id="myUrl" value="clickme" />
<s:a href="%{myUrl}" theme="simple">Click here.</s:a>
<%-- With an action --%>
<s:url id="myUrl" action="clickme" />
<s:a href="%{myUrl}" theme="simple">Click here.</s:a>
顺便说一句,您不需要表单的action属性的上下文路径:
By the way, you don't need a context path for the action attribute of a form:
<s:form method="post" action="submitme" theme="simple"></s:form>