我需要将参数从jsp发送到servlet,但只更新一行而不是更新servlet生成的所有行。 你能帮帮我吗? 我的servlet代码是:
public class ExcelTest extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//processRequest(request, response);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
//out.println(request.getParameter("customerName"));
for (int i = 0; i < 250; i++){
out.println("<input + id = " + i + " type=\"text\" value = " + request.getParameter("customerName") + ">");
request.setAttribute("vvv", i);
out.println("<a href=\"http://localhost:8079/TesteExcel/createparameters.jsp\">Visit</a>");
out.println("<div>");
for (int j = 0; j < 10; j++){
out.print("<div id = " + i + "" + j + " style=\"width:100px; float:left\">" + i + " - " + j +"</div>");
}
out.println("</br>");
out.println("</div>");
}
}
}
并且对于jsp是:
<form name="excel" action="ExcelTest" method="post">
<input type="text" name="customerName">
<input type="text" name="customerCUI">
<input type=submit value="click me">
</form>
谢谢你, 椰油
答案 0 :(得分:0)
试试这个
String custName = request.getParameter("customerName");
for (int i = 0; i < 250; i++){
if(i!=0)
custName="";
out.println("<input + id = " + i + " type=\"text\" value = " + custName + ">");
request.setAttribute("vvv", i);
out.println("<a href=\"http://localhost:8079/TesteExcel/createparameters.jsp\">Visit</a>");
out.println("<div>");
for (int j = 0; j < 10; j++){
out.print("<div id = " + i + "" + j + " style=\"width:100px; float:left\">" + i + " - " + j +"</div>");
}
out.println("</br>");
out.println("</div>");
}
仅对于第一次迭代,它将需要customer name
。
这里我假设您在每次迭代中都需要input
标记。