search
HomeWeb Front-endHTML TutorialWeb development jsp java MVC A detailed question about form_html/css_WEB-ITnose

This is an order display and there is a button to cancel the order
This link button should be placed in the form
But because my order is transferred from the database
I don’t know how many orders there are.
So the form should also be dynamically generated
You can write it like this, using only one form and one order
If you put the form in the loop, it will be useless
It looks like this
ReserveList There are already multiple order objects stored in it

for(int i=0;i< ReserveList.size();i++) {out.println("<form name='form7'action='/g0103/servlet/servBDReserveCancel?rnum="+ReserveList.get(0).getReserveNum()+"' method='post'><a href='javascript:form"+(i+7)+".submit()' class='btn_buy' >取消</a></form>");}

What should I do? ? ?
I have been thinking about it for a long time but there is no way. . . Help


Complete code
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();		ArrayList<voBDReserve> ReserveList=new ArrayList<voBDReserve>();			daoBDReserve daoBDReserve = new daoBDReserve();		daoBDReserveDetail daoBDReserveDetail = new daoBDReserveDetail();        String membernum=request.getParameter("mnum");         ReserveList=daoBDReserve.showReserve(membernum);         if(membernum!=null){	        				out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");			out.println("<HTML>");			out.println("<head>");			out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />");			out.println("<title>Reserve</title>");			out.println("<link href='../ky/css/style.css' rel='stylesheet' type='text/css' media='all' />");			out.println("<link href='../ky/css/font.css' rel='stylesheet' type='text/css'>");				out.println("<link href='../ky/css/new.css' rel='stylesheet' type='text/css' media='all' />");			out.println("</head>");			out.println("<body>");			out.println("<div class='header'>");			out.println("<div class='header-left-w'>");			out.println("<div class='logo'>");			out.println("<a href='../ky/index.jsp?mnum="+membernum+"'><img  src='../ky/images/logo.png' alt="Web development jsp java MVC A detailed question about form_html/css_WEB-ITnose" ></a>");			out.println("</div>");			out.println("<div class='top-nav'>");			out.println("<ul >");			out.println("<li><a href='../ky/index.jsp?mnum="+membernum+"' >主页</a></li>");			out.println("<li><a href='../ky/intro.jsp?mnum="+membernum+"' class='black' > 简介</a></li>");				out.println("<li><form name='form1' action='/g0103/servlet/servDTRoomTypeShow?mnum="+membernum+"' method='post'><a href='javascript:form1.submit()' class='black1'> 预定</a></form></li>");			out.println("<li  class='active' ><form name='form2' action='/g0103/servlet/servBDReserveShow?mnum="+membernum+"' method='post'><a href='javascript:form2.submit()' class='black1'> 预定信息</a></form></li>");			out.println("<li><form name='form3' action='/g0103/servlet/servBEMemberShow?mnum="+membernum+"' method='post'><a href='javascript:form3.submit()' class='black1'> 会员信息</a></form></li>");			out.println("<li><a href='../ky/login.jsp' class='black4' > 登录</a></li>");			out.println("</ul>");			out.println("</div>");					out.println("</div>");					out.println("<div class='header-top'>");			out.println("<div class='logo-in'>");			out.println("<a href='../ky/index.jsp?mnum="+membernum+"'><img  src=../ky/images/logo.png alt="Web development jsp java MVC A detailed question about form_html/css_WEB-ITnose" ></a>");			out.println("</div>");			out.println("<div class='top-nav-in'>");			out.println("<span class='menu'><img  src='../ky/images/menu.png' alt="Web development jsp java MVC A detailed question about form_html/css_WEB-ITnose" > </span>");			out.println("<ul >");			out.println("<li><a href='../ky/index.jsp?mnum="+membernum+"' >主页</a></li>");			out.println("<li><a href='../ky/intro.jsp?mnum="+membernum+"' class='black' > 简介</a></li>");				out.println("<li><form name='form4' action='/g0103/servlet/servDTRoomTypeShow?mnum="+membernum+"' method='post'><a href='javascript:form4.submit()' class='black1'> 预定</a></form></li>");			out.println("<li class='active' ><form name='form5' action='/g0103/servlet/servBDReserveShow?mnum="+membernum+"' method='post'><a href='javascript:form5.submit()' class='black1'> 预定信息</a></form></li>");			out.println("<li><form name='form6' action='/g0103/servlet/servBEMemberShow?mnum="+membernum+"' method='post'><a href='javascript:form6.submit()' class='black1'> 会员信息</a></form></li>");			out.println("<li><a href='../ky/login.jsp?mnum="+membernum+"' class='black4' > 登录</a></li>");									out.println("<form name='form7'action='/g0103/servlet/servBDReserveCancel?rnum="+ReserveList.get(0).getReserveNum()+"' method='post'></form>");						out.println("</ul>");			out.println("<script>");			out.println("$('span.menu').click(function(){");			out.println("$('.top-nav-in ul').slideToggle(500, function(){");			out.println("});");			out.println("});");			out.println("</script>");			out.println("</div>");			out.println("<div class='clear'> </div>");						out.println("</div>");									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("<div class='content'>");				out.println("<div class='work'>");				out.println("<div class='htl_room_list_box'>");				out.println("<ul class='htl_room_list'>");							 				out.println("<div class='htl_room_info'>");				out.println("<h4 id="订单-i">订单"+(i+1)+"</h4>");				out.println("<p class='info'><span class='divide'>|</span>订单号:"+voBDReserve0.getReserveNum()+"</p>");				out.println(" <table class='htl_room_tb'>");				out.println("<tbody>");				out.println("<tr>");				out.println("<th></th>");				out.println("<th>订单状态</th>");				out.println("<th>入住时间</th>");				out.println("<th>入住天数</th>");				out.println("<th>房间类型</th>");				out.println("<th>总价<strong></strong></th>");				out.println("<th class='th_room_booking'></th>");				out.println("</tr>");										 				out.println("<tr class='J_needHidePrice'> ");				out.println("<td>明细</span></td>");				out.println("<td>"+voBDReserveDetail0.getResstateNum()+"</td>");				out.println("<td>"+voBDReserveDetail0.getCheckInTime()+"</td>");								out.println("<td>"+voBDReserveDetail0.getStayDays()+"</td>");				out.println("<td>"+voRoomType.getTypeName()+"</span></td>");				out.println("<td>"+voBDReserve0.getFontMoney()+"元</span></td>");				out.println("<td>");				out.println("<a href='javascript:form"+(i+7)+".submit()' class='btn_buy' >取消</a>");				out.println("</td>");				out.println("</tr>");				out.println("</tbody>");				out.println("</table>");				out.println("</div>");								out.println("</ul>"); 				out.println(" ");				out.println("</div>");				out.println("</div>");				out.println("</div>");				out.println("</div>");  						out.println("</body>");				out.println("</html>");			}		} 	}        }


Reply to discussion (solution)

You should To ask this question in the JavaEE module, go to http://bbs.csdn.net/forums/J2EE.
In addition, you have said that it is MVC, and the view and model are separated:
The HTML content of the page should be written in JSP.
Just pass the ReserveList object in the servlet and display it using EL or JSTL.

As for the problem you encountered, you can use Ajax instead of directly using Form to submit the form;
Like a general list page, each row (item) has a delete button. Click the delete button,
will pass the item ID to the server through Ajax for deletion, and then provide feedback and so on.

You wrap each order with

, just to exchange with the server (servlet),
pass the order ID to the server for deletion;
and the server There are generally two ways to exchange: form submission and Ajax.
Form submission is generally used when clicking "Submit" will jump to the page or refresh the page;
Ajax is generally used to submit data without jumping (when the entire page remains roughly unchanged). server.
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft