我有兩個jsp文件。在第一個文件中顯示文件的表,并且在代碼中我可以訪問一個值(文件的 ID)。這也是一個彈出窗口。如果文件分配了注釋,則該注釋將顯示在表中。如果沒有,則會在其位置顯示一個用于添加注釋的按鈕。單擊按鈕后,我們調用第二個文件中的代碼,并打開一個彈出窗口。我想訪問第二個文件中的文件 ID。第一個文件(所以在這里我調用某個地方的 id${na.id}我將獲取每個文件的 id):<div id="files-list-${bean.product.id}"> <table class="table"> <thead> <tr> <th>File</th> <th>Notes</th> </tr> </thead> <tbody> <c:if test="${fn:length(bean.product.files)>0}"> <c:forEach items="${bean.product.files}" var="na"> <tr> <td>${na.name}</td> <td> <c:if test="${empty na.note}"> <t:jquery func="myDialog('filesNotes',${bean.product.id},${bean.product.version})">Add note</t:jquery> </c:if> <c:if test="${not empty na.note}"> ${na.note} </c:if> </td> </tr> </c:forEach> </c:if> </tbody> </table> </div>第二個文件(彈出窗口)- 這里${bean.fileId}操作 URL 為空:<div id="filesNotes" class="classA" title="Notes"> <form:form role="form" method="POST" modelAttribute="bean" action="app/updateFile.ajax?id=${bean.product.id}&fileId=${bean.fileId}" onsubmit="return postAjaxForm(this)"> <form:hidden path="id" value="${bean.product.id}" /> <input type="hidden" name="version" value="${bean.product.version}" /> <form:textarea path="product.scratchpad" htmlEscape="true" cssClass="form-control" rows="17" cols="63"/> </form:form></div>myDialog 函數:(注意我不擅長 js 和前端:))function myDialog(id, oid, oversion){ if($("#"+id).length < 1){ alert("not found element #"+id); return;
在父彈出窗口和子彈出窗口/jsp頁面之間傳遞值
慕尼黑5688855
2023-10-24 15:12:44