springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-19 11:56:36
152
我正在使用express和Node.js创建一个web应用程序。我有一个表,它是用来自数据库的数据使用ejs生成的。下面是创建表的代码:
<form action="/user-orders" method="POST">
<table id="order-history">
<thead>
<tr>
<th>Date of Order</th>
<th>Order ID</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Tracking Info</th>
<th>Order Details</th>
</tr>
</thead>
<tbody>
<% orders.forEach(function(order){ %>
<tr>
<td name="date"><%= order.date%></td>>
<td name="id"><%= order.id%></td>
<td name="cost"> $<%= order.cost.toFixed(2) %></td>
<td name="status"><%= order.status%></td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewTracking" value="View" id="viewTracking">
</td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewOrder" value="View" id="viewOrder">
</td>
</tr>
<% }) %>
</tbody>
</table>
</form>
我想知道的是,当我单击其中一个按钮时,如何从选定的行中获取值。
即:单击第1行中的视图将返回:
<form action="/user-orders" method="POST">
<table id="order-history">
<thead>
<tr>
<th>Date of Order</th>
<th>Order ID</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Tracking Info</th>
<th>Order Details</th>
</tr>
</thead>
<tbody>
<% orders.forEach(function(order){ %>
<tr>
<td name="date"><%= order.date%></td>>
<td name="id"><%= order.id%></td>
<td name="cost"> $<%= order.cost.toFixed(2) %></td>
<td name="status"><%= order.status%></td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewTracking" value="View" id="viewTracking">
</td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewOrder" value="View" id="viewOrder">
</td>
</tr>
<% }) %>
</tbody>
</table>
</form>
我尝试了下面的两个代码片段,但它们都返回未定义:
<form action="/user-orders" method="POST">
<table id="order-history">
<thead>
<tr>
<th>Date of Order</th>
<th>Order ID</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Tracking Info</th>
<th>Order Details</th>
</tr>
</thead>
<tbody>
<% orders.forEach(function(order){ %>
<tr>
<td name="date"><%= order.date%></td>>
<td name="id"><%= order.id%></td>
<td name="cost"> $<%= order.cost.toFixed(2) %></td>
<td name="status"><%= order.status%></td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewTracking" value="View" id="viewTracking">
</td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewOrder" value="View" id="viewOrder">
</td>
</tr>
<% }) %>
</tbody>
</table>
</form>
顺晟科技:
由于整个文件只包含一个,所以无论单击哪个提交按钮,所有行的内容都将提交到,并且字段名将重复,正如前面指出的那样。
最好每行有一个,然后只提交该行的内容。
注意,HTML表单将以urlencoded格式提交数据,如
<form action="/user-orders" method="POST">
<table id="order-history">
<thead>
<tr>
<th>Date of Order</th>
<th>Order ID</th>
<th>Order Total</th>
<th>Order Status</th>
<th>Tracking Info</th>
<th>Order Details</th>
</tr>
</thead>
<tbody>
<% orders.forEach(function(order){ %>
<tr>
<td name="date"><%= order.date%></td>>
<td name="id"><%= order.id%></td>
<td name="cost"> $<%= order.cost.toFixed(2) %></td>
<td name="status"><%= order.status%></td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewTracking" value="View" id="viewTracking">
</td>
</td>
<td><input type="submit" class="profile-edit-btn"
style="color:#0062cc; background:rgb(29, 29, 29); width:100%"
name="viewOrder" value="View" id="viewOrder">
</td>
</tr>
<% }) %>
</tbody>
</table>
</form>
能否解析此格式?
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11