使用 window.showModalDialog(url, ...) 打開頁面,URL 帶參數 ?acceptanceIds=xxx,但後台 Action 直接接收參數為 null。
showModalDialog 打開的窗口無法直接將 URL 參數傳遞給後台 Action,需經過中間頁面中轉。
var url = "popub_acceptance.jsp?acceptanceIds=" + $("#acceptanceIds").val();
var returnValue = showModalDialog(url, 1000, 600);
<%@ page contentType="text/html;charset=UTF-8" %>
<%
String queryString = request.getQueryString(); // 獲取完整查詢字符串
%>
<html>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<table width="100%" border="0" height="100%">
<tr>
<td>
<iframe id="iframe_list"
src="loadAcceptance.action?<%=queryString%>"
frameborder="0" width="100%" height="100%"
scrolling="auto" align="center" valign="top">
</iframe>
</td>
</tr>
</table>
</body>
</html>
public String loadAcceptance() {
if (StringUtils.isNotBlank(acceptanceIds)) {
ascceptances = expenseService.loadAscceptances(acceptanceIds, getBmYear());
}
return "ascceptances_detail";
}
showModalDialog 打開中轉 JSPrequest.getQueryString() 獲取完整參數src 動態拼接參數請求真實 ActionshowModalDialog 已被主流瀏覽器棄用/移除,建議遷移至:
新方案天然支持參數傳遞、響應式、移動端適配,無需中轉頁面繞彎。