<p></p>
<pre class="blockcode"><code class="language-java">1. 主页面</code></pre>
<p></p>
<p></p>
<pre class="blockcode"><code class="language-java"><%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<a href="${pageContext.request.contextPath }/showAll">点击查询所有商品信息</a>
</body>
</html></code></pre>
<br>
<br>
<p></p>
<p>2.查询全部页面</p>
<p></p>
<pre class="blockcode"><code class="language-java"><%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/imagetable.css">
<script type="text/javascript">
function add(){
location.href="${pageContext.request.contextPath}/findClist"
}
</script>
</head>
<body>
<table border="1" width="40%" class="imagetable" align="center">
<tr>
<th>商品列表</th>
</tr>
</table>
<hr/>
<table border="1" width="100%" class="imagetable">
<tr>
<th colspan="6" align="right">
<input type="button" value="添加商品" οnclick="add()"/>
</th>
</tr>
<tr>
<th>商品序号</th>
<th>商品名称</th>
<th>商品图片</th>
<th>商品价格</th>
<th colspan="2">商品描述</th>
</tr>
<c:if test="${not empty plist}">
<!-- 做一个判断,防止空指针异常-->
<!-- 遍历设置值 -->
<!-- 这里是el表达式,注意!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<c:forEach items="${plist }" var="product" varStatus="con">
<tr>
<td>${con.count }</td>
<td>${product.pname}</td>
<td>
<img src="${pageContext.request.contextPath }/${product.pimage }" width="100%">
</td>
<td>${product.shop_price }</td>
<td>${product.pdesc }</td>
<!--从保存在request中的product获取pid对象,并通过形参传递的方式,传过去 -->
<td><a href="${pageContext.request.contextPath}/update?pid=${product.pid}">修改商品</a>
<a href="${pageContext.request.contextPath}/delete?pid=${product.pid}">删除商品</a>
</td>
</tr>
</c:forEach>
</c:if>
</table>
</body>
</html></code></pre>
<br>
<br>
<p></p>
<p>3.添加页面</p>
<p></p>
<pre class="blockcode"><code class="language-java"><%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/imagetable.css">
</head>
<body>
<table border="1" width="40%" class="imagetable" align="center">
<tr>
<th>添加商品</th>
</tr>
</table>
<hr/>
<!-- 添加商品信息页面 -->
<form action="${pageContext.request.contextPath }/add" method="post">
<table border="1" width="100%" class="imagetable">
<tr>
<td>商品名称</td>
<td>
<input type="text" name="pname" />
</td>
</tr>
<tr>
<td>商品售价</td>
<td>
<input type="text" name="shop_price" />
</td>
</tr>
<tr>
<td>商品图片</td>
<td>
<input type="text" name="pimage" />
</td>
</tr>
<tr>
<td>商品描述</td>
<td>
<textarea name="pdesc"></textarea>
</td>
</ |
|