用jsp写一个关于购物车的前端页面
时间: 2023-10-30 19:05:03 浏览: 41
以下是一个简单的购物车前端页面示例,使用JSP实现:
```jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>购物车</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
border: 1px solid #ddd;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>购物车</h1>
<table>
<thead>
<tr>
<th>商品名称</th>
<th>价格</th>
<th>数量</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>商品1</td>
<td>100元</td>
<td>2</td>
<td><button class="button">删除</button></td>
</tr>
<tr>
<td>商品2</td>
<td>50元</td>
<td>1</td>
<td><button class="button">删除</button></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">总价</td>
<td>250元</td>
</tr>
</tfoot>
</table>
</body>
</html>
```
该页面包含一个简单的HTML表格,显示购物车中的商品、价格、数量和操作。每行都有一个“删除”按钮,单击该按钮会从购物车中删除该商品。
在这个示例中,总价是在表格的tfoot中显示的,但您也可以根据需要将其放在其他位置。