这是一个订单展示然后有一个按钮取消订单的
这个链接按钮应该是放在form里
但是因为我的订单是从数据库里调的
不知道有多少个订单
所以form也应该是动态生成的
像我这样写可以 只用了一个form 一个订单
要是把form放到循环里就没用了
就是下面这样
ReserveList里面已经存好了多个订单对象
for(int i=0;i< ReserveList.size();i++) {out.println("");}
该怎么办???
想了好久都没有办法。。。求助
完整代码
package serv.BD;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import dao.BD.daoBDReserve;import dao.BD.daoBDReserveDetail;import dao.DT.daoDTRoomType;import vo.BD.voBDReserve;import vo.BD.voBDReserveDetail;import vo.DT.voDTRoomType;@SuppressWarnings("serial")public class servBDReserveShow extends HttpServlet { public servBDReserveShow() { super(); } public void destroy() { super.destroy(); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset==utf-8"); request.setCharacterEncoding("gb2312"); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); ArrayListReserveList=new ArrayList (); daoBDReserve daoBDReserve = new daoBDReserve(); daoBDReserveDetail daoBDReserveDetail = new daoBDReserveDetail(); String membernum=request.getParameter("mnum"); ReserveList=daoBDReserve.showReserve(membernum); if(membernum!=null){ out.println(""); out.println(""); out.println(""); out.println(""); out.println(" Reserve "); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println("
"); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(" "); out.println("- 主页
"); out.println("- 简介
"); out.println(""); out.println(""); out.println(""); out.println("- 登录
"); out.println(""); out.println("
"); out.println(""); out.println(""); out.println(""); out.println(" "); out.println(""); for(int i=0;i< ReserveList.size();i++) { voBDReserve voBDReserve0 = new voBDReserve(); voBDReserve0=ReserveList.get(i); voBDReserveDetail voBDReserveDetail0 = new voBDReserveDetail(); voBDReserveDetail0=daoBDReserveDetail.showReserveDetail(voBDReserve0.getReserveNum()); voDTRoomType voRoomType=new voDTRoomType(); daoDTRoomType daoRoomType=new daoDTRoomType(); voRoomType=daoRoomType.finDTRoomType(voBDReserveDetail0.getTypeNum()); out.println(""); out.println(""); out.println(""); out.println("- 主页
"); out.println("- 简介
"); out.println(""); out.println(""); out.println(""); out.println("- 登录
"); out.println(""); out.println(""); out.println("
"); out.println(" "); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); } } } }订单"+(i+1)+"
"); out.println("|订单号:"+voBDReserve0.getReserveNum()+"
"); out.println(""); out.println(""); out.println("
"); out.println(""); out.println(""); out.println(" "); out.println(""); out.println(" 订单状态 "); out.println("入住时间 "); out.println("入住天数 "); out.println("房间类型 "); out.println("总价 "); out.println(""); out.println(" "); out.println(" "); out.println(""); out.println("明细 "); out.println(""+voBDReserveDetail0.getResstateNum()+" "); out.println(""+voBDReserveDetail0.getCheckInTime()+" "); out.println(""+voBDReserveDetail0.getStayDays()+" "); out.println(""+voRoomType.getTypeName()+" "); out.println(""+voBDReserve0.getFontMoney()+"元 "); out.println(""); out.println("取消"); out.println(" "); out.println("
回复讨论(解决方案)
你应该到JavaEE模块里去问这个问题,移步 http://bbs.csdn.net/forums/J2EE。
另外,你都说了是 MVC, view和model分离:
页面HTML内容应该在JSP中写,
在servlet中把 ReserveList对象传过去用EL、JSTL展示即可。
至于你遇到的问题,你可以使用Ajax,而不直接使用Form提交表单的方式;
像一般的列表页,每个行(item)都有个删除的按钮,点击删除按钮,
就通过Ajax把这个item的ID传到服务器进行删除,然后反馈等等。
你把每个订单都用