12.13
今天完成了商品系统;没有遇到什么问题,实现了数据的增删改查,和一些附属功能,明天计划写一个新的web系统
下面是代码部分:与前几天的合起来就是一个完整的商品系统,不过在前几个代码的基础上又增加了点。下面是新增代码,没改动的代码这里就不写了。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>功能选择界面</title>
</head>
<body>
<form>
<table align="center" border="1">
<tr align="center">
<td>
<input type="submit" value="增加商品" formaction="add.jsp" formmethod="post">
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="删除商品" formaction="delete.jsp " formmethod="post">
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="修改商品" formaction="update.jsp" formmethod="post">
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="买商品" formaction="servlet?method=show" formmethod="post">
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>认证界面</title>
</head>
<body>
<script>
var add='<%=request.getParameter("add")%>';
if(add=="yes"){
alert("添加成功!");
}
</script>
<form action="servlet?method=login&name=name1" method="post">
<table align="center">
<tr>
<td>名字:</td>
<td>
<input type="text" name="mingzi">
</td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="text" name="sex">
</td>
</tr>
<tr>
<td>年龄:</td>
<td>
<input type="text" name="age">
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="确定" >
<input type="submit" value="返回" formaction="people.jsp" formmethod="post">
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ 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>
<html>
<head>
<meta charset="UTF-8">
<title>显示页面</title>
</head>
<body>
<form>
<table>
<tr>
<td>商品名称</td>
<td>商品价格</td>
<td>数量</td>
<td>选择</td>
</tr>
<tr>
<c:forEach items="${list}" var="item">
<tr>
<td>${item.name}</td>
<td>${item.jiage}</td>
<td>${item.shuliang}</td>
<td><input type="submit" value="选择" formaction="people.jsp" formmethod="post"></td>
</tr>
</c:forEach>
</tr>
<tr>
<td>
<input type="submit" value="返回" formaction="gongneng.jsp" formmethod="post">
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改分数页面</title>
</head>
<body>
<script>
var update='<%=request.getParameter("update")%>';
if(update=='yes'){
alert("修改成功!");
}
</script>
<form action="servlet?method=update" method="post">
<table align="center">
<tr>
<td>请输入要修改商品名称:</td>
<td>
<input type="text" name="name">
</td>
</tr>
<tr>
<td>请输入要修改后的商品名称:</td>
<td>
<input type="text" name="name1">
</td>
</tr>
<tr>
<td>请输入修改价格:</td>
<td>
<input type="text" name="jiage">
</td>
</tr>
<tr>
<td>请输入修改数量:</td>
<td>
<input type="text" name="shuliang">
</td>
</tr>
<tr align="center">
<td>
<input type="submit" value="确定">
<input type="submit" value="返回" formaction="gongneng.jsp" formmethod="post">
</td>
</tr>
</table>
</form>
</body>
</html>
数据库部分:
运行结果部分: