【发布时间】:2013-11-25 15:43:51
【问题描述】:
在我的 struts2 应用程序中,我有一个 JavaScript 函数来执行取消操作。此方法位于标头中,仅对我的返回 URL 执行 window.location。由于我们从 struts 2.3.8 版本的 2.0.11 版本进行了迁移,它不再有效。当我查看生成的 HTML 代码时,我们看到无法解释标记 s:property,因为 URL 为空。我看不出什么不起作用。
在我的 IDE 中:
function cancel() {
if (!isModified || (isModified && askConfirmCancel())) {
window.location.replace('<s:property value="#urlBack"/>');
}
}
Firebug 的结果:
function cancel() {
if (!isModified || (isModified && askConfirmCancel())) {
window.location.replace('');
}
}
在 JSP 文件中:
<tr>
<td height="6%"align="center">
<s:submit cssClass="button" key="common.initDelegate.label" align="center" theme="simple"/>
<s:url id="urlBack" action="myAction" includeParams="none" escapeAmp="false">
<s:param name="period.periodId" value="%{period.periodId}"></s:param>
</s:url>
<input type="button" onclick="javascript:cancel()" value="<s:text name="common.button.cancel"/>"/>
</td>
</tr>
【问题讨论】:
-
也可以直接使用参数化的
url标签。
标签: java javascript jsp struts2