日期:2014-05-17 浏览次数:20851 次
String cNumber = request.getParameter("cnumber"); String cID = request.getParameter("cid"); int id = Integer.parseInt(cID); String aName = request.getParameter("name"); String aDepart = request.getParameter("dept"); String aReason = request.getParameter("reason"); String aTime = request.getParameter("date"); String status = "1"; String path = null; List<Record> list=null; boolean uFlag,iFlag; try { //此方法为申请车辆的方法,一申请就改变车辆的当前状态 uFlag = CarsFactory.getCarsDAOInstances().UpdateStatus(id, status); //此方法将申请记录插入到数据库 iFlag=CarsFactory.getRecordDAOInstances().doInsertResord(cNumber, aName, aDepart, aReason, aTime); //此方法获取车牌号码对应的申请记录 list=CarsFactory.getRecordDAOInstances().querryByRid(cNumber); if (uFlag&iFlag) { //申请成功将申请的信息发送给浏览器 request.setAttribute("redList", list); path = "cars/querryapp.jsp"; } else { path = "errors/Error.jsp"; } request.getRequestDispatcher(path).forward(request, response); } catch (Exception e) { System.out.print(e); }
<jason:forEach items="${redList}" var="record"> <tr> <td height="25" align="center"> ${record.rid} </td> <td align="center"> ${record.cno} </td> <td align="center"> ${record.owner } </td> <td align="center"> ${record.departName } </td> <td align="center"> ${record.reason } </td> <td align="center"> ${record.date } </td> </tr> </jason:forEach>
//此方法将申请记录插入到数据库 iFlag=CarsFactory.getRecordDAOInstances().doInsertResord(cNumber, aName, aDepart, aReason, aTime);
------解决方案--------------------
每次刷新页面,就会向服务器发送一次请求,就会执行一次dopost方法,就会执行一次插入操作。。。so。