我试图在servlet刷新后保留一个参数。我尝试了会议,但它不会工作。任何人都可以帮助我
@覆盖 protected void doGet(HttpServletRequest请求,HttpServletResponse响应) 抛出ServletException,IOException {
String equip = request.getParameter("name");
String qty = request.getParameter("qty");
String equipId = null;
//HttpSession session = request.getSession();
//String itemId = (String) session.getAttribute("repId");
String itemId = request.getParameter("repId");
HttpSession session = request.getSession();
session.setAttribute("id", itemId);
//System.out.println(equip);
//System.out.println(qty);
System.out.println(itemId);
String itemId1 = (String)session.getAttribute("id");
System.out.println(itemId1);
try {
DB_Connection db = new DB_Connection();
Connection conn = db.getDBconnection();
Statement stmt1 = conn.createStatement();
ResultSet rs1 = stmt1.executeQuery("SELECT id from equipment where name='"+equip+"'");
while(rs1.next()){
equipId=(String)rs1.getString("id");
//System.out.println(equipId);
}
String insertString1 = "INSERT INTO used_equipment"
+ "(item_id, eqp_id, qty) VALUES"
+ "(?,?,?)";