【发布时间】:2016-03-11 09:28:24
【问题描述】:
我有两个 jsp 文件,jsp1 和 jsp2。当点击 jsp1 上的编辑按钮时,将调用 java 脚本函数。从javascript函数我调用jsp2。我使用 window.open 因为我需要这个 jsp2 作为弹出窗口打开。现在我想在单击编辑按钮时将一个对象从 jsp1 传递到 jsp2。我该怎么做?
This is my code
jsp1
< script language="JavaScript">
function edit(){
window.open("jsp2.jsp",'popuppage',"height=600,width=800,status=yes,toolbar=no,menubar=no,location=no");
return true;
}
< /script>
< stripes:form name="upload"
action="/upload.action" enctype="multipart/form-data">
< table>
<% List<TableDto> list = (List<TableDto>)request.getAttribute("table"); %>
<%
if(list != null){
for (TableDto dto : list) {
%>
< tr>
<td><%=dto.getName()%></td>
<td><img src="<%=dto.getPath() %>" width="40px"
height="40px" /></td>
<td><%=dto.getText()%></td>
<td>
<input type="image" name="edit"onclick="edit()"
src="${globalPath}/images/edit_pen.jpg">
< /tr>
<%
}
}
%>
</table>
< /stripes:form>
【问题讨论】:
-
你可以尝试使用
postMessagedeveloper.mozilla.org/en-US/docs/Web/API/Window/postMessage或者添加get参数window.open("jsp2.jsp?foo=bar",... -
@FrederikWitte 这是不同的问题,因为它使用
include加载第二个文件。
标签: javascript java jsp