add.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加信息</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加信息</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: blue;">添加信息</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet method=add" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" />
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//判断是否空
if(name.value == '')
{
alert('名字为空');
name.focus();
return false;
}
if(grade.value == '')
{
alert('分数为空');
place.focus();
return false;
}
}
</script>
</body>
</html>
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: blue;">添加信息</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet method=add" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" />
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//判断是否空
if(name.value == '')
{
alert('名字为空');
name.focus();
return false;
}
if(grade.value == '')
{
alert('分数为空');
place.focus();
return false;
}
}
</script>
</body>
</html>
del.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: blue;">信息删除</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet?method=getcoursebyname" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
<button type="submit" class="b">查 找</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");
//非空
if(name.value == '')
{
alert('姓名为空');
name.focus();
return false;
}
}
</script>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: blue;">信息删除</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet?method=getcoursebyname" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
<button type="submit" class="b">查 找</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");
//非空
if(name.value == '')
{
alert('姓名为空');
name.focus();
return false;
}
}
</script>
</body>
</html>
detail.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>按ID查询</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">信息删除</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>姓名</td>
<td>${course.name}</td>
</tr>
<tr>
<td>分数</td>
<td>${course.grade}</td>
</tr>
</table>
<div class="a">
<a onclick="return check()" href="servlet?method=del&id=${course.id}">删 除</a>
</div>
</div>
<script type="text/javascript">
function check() {
if (confirm("真的要删除吗?"))
{
return true;
}
else
{
return false;
}
}
</script>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>按ID查询</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">信息删除</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>姓名</td>
<td>${course.name}</td>
</tr>
<tr>
<td>分数</td>
<td>${course.grade}</td>
</tr>
</table>
<div class="a">
<a onclick="return check()" href="servlet?method=del&id=${course.id}">删 除</a>
</div>
</div>
<script type="text/javascript">
function check() {
if (confirm("真的要删除吗?"))
{
return true;
}
else
{
return false;
}
}
</script>
</body>
</html>
detail2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>按名字查询</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: red;">物资信息修改</h1>
<a href="index.jsp">返回主页</a>
<form action="CourseServlet?method=update" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name" value="${course.name}"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" value="${course.grade}"/>
</div>
<input type="hidden" id="id" name="id" value="${course.id}"/>
<div class="a">
<button type="submit" class="b">修 改</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//非空
if(name.value == '')
{
alert('姓名为空');
name.focus();
return false;
}
if(grade.value == '')
{
alert('分数为空');
place.focus();
return false;
}
}
</script>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>按名字查询</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: red;">物资信息修改</h1>
<a href="index.jsp">返回主页</a>
<form action="CourseServlet?method=update" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name" value="${course.name}"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" value="${course.grade}"/>
</div>
<input type="hidden" id="id" name="id" value="${course.id}"/>
<div class="a">
<button type="submit" class="b">修 改</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//非空
if(name.value == '')
{
alert('姓名为空');
name.focus();
return false;
}
if(grade.value == '')
{
alert('分数为空');
place.focus();
return false;
}
}
</script>
</body>
</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
.a{
font-size: 26px;
margin-top: 20px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">查分系统</h1>
<div class="a">
<a href="add.jsp">添加信息</a>
</div>
<div class="a">
<a href="servlet?method=list">信息修改</a>
</div>
<div class="a">
<a href="del.jsp">信息删除</a>
</div>
<div class="a">
<a href="search.jsp">信息搜索</a>
</div>
</div>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
.a{
font-size: 26px;
margin-top: 20px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">查分系统</h1>
<div class="a">
<a href="add.jsp">添加信息</a>
</div>
<div class="a">
<a href="servlet?method=list">信息修改</a>
</div>
<div class="a">
<a href="del.jsp">信息删除</a>
</div>
<div class="a">
<a href="search.jsp">信息搜索</a>
</div>
</div>
</body>
</html>
list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>遍历</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: red;">信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>姓名</td>
<td>分数</td>
<td align="center" colspan="2">操作</td>
</tr>
<c:forEach items="${courses}" var="item">
<tr>
<td>${item.id}</td>
<td>${item.name}</td>
<td>${item.grade}</td>
<td><a href="servlet?method=getCourseById&id=${item.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>遍历</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: red;">信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>姓名</td>
<td>分数</td>
<td align="center" colspan="2">操作</td>
</tr>
<c:forEach items="${courses}" var="item">
<tr>
<td>${item.id}</td>
<td>${item.name}</td>
<td>${item.grade}</td>
<td><a href="servlet?method=getCourseById&id=${item.id}">修改</a></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
search.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>搜索</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">物资信息查询</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet?method=search" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" />
</div>
<div class="a">
<button type="submit" class="b">查 询</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//非空
if(name.value == '' && grade.value == '' )
{
alert('请填写一个条件');
return false;
}
}
</script>
</body>
</html>
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>搜索</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: blue;">物资信息查询</h1>
<a href="index.jsp">返回主页</a>
<form action="servlet?method=search" method="post" onsubmit="return check()">
<div class="a">
姓名<input type="text" id="name" name="name"/>
</div>
<div class="a">
分数<input type="text" id="grade" name="grade" />
</div>
<div class="a">
<button type="submit" class="b">查 询</button>
</div>
</form>
</div>
<script type="text/javascript">
function check()
{
var name = document.getElementById("name");;
var grade = document.getElementById("grade");
//非空
if(name.value == '' && grade.value == '' )
{
alert('请填写一个条件');
return false;
}
}
</script>
</body>
</html>
searchlist.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: red;">信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>姓名</td>
<td>分数</td>
</tr>
<!-- forEach遍历出adminBeans -->
<c:forEach items="${courses}" var="item" varStatus="status">
<tr>
<td>${item.id}</td>
<td><a>${item.name}</a></td>
<td>${item.grade}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
.a{
margin-top: 20px;
}
.b{
font-size: 20px;
160px;
color: white;
background-color: greenyellow;
}
.tb, td {
border: 1px solid black;
font-size: 22px;
}
</style>
</head>
<body>
<div align="center">
<h1 style="color: red;">信息列表</h1>
<a href="index.jsp">返回主页</a>
<table class="tb">
<tr>
<td>id</td>
<td>姓名</td>
<td>分数</td>
</tr>
<!-- forEach遍历出adminBeans -->
<c:forEach items="${courses}" var="item" varStatus="status">
<tr>
<td>${item.id}</td>
<td><a>${item.name}</a></td>
<td>${item.grade}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
jsp部分