大家好,我正在尝试使用 java 脚本访问转发的请求,双方的代码部分如下所示:
客户端
function addRow() {
var numRows = document.getElementById("request").getAttributeNode("numOfExt");
var table = document.getElementByName("extensionTable");
var allExtensions = new Array();
allExtensions = document.getElementById("request").getAttributeNode("extensions");
for ( var i = 0; i < numRows; i++) {
var row = table.insertRow(i);
var cell1 = row.insertCell();
cell1.innerHTML = allExtensions[i];
}
}
小服务程序
request.setAttribute("numOfExt", extensionHandler.getExtensions()
.size());
request.setAttribute("extensions", extensionHandler.getExtensions()
.toString());
// forward the httpServlet
getServletContext().getRequestDispatcher("/index.jsp").forward(request,
response);
谢谢你的帮助!