11.30
今天完成了web 系统的增删改查操作,没有遇道什么问题,明天计划继续写web系统;
代码部分;
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="../AddServlet" method="post">
<input type="text" name="name">
<input type="submit" value="注册" >
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div><input type="text" id="name" name="name"></div>
<div><input type="button" value="保存" onclick="change()"></div>
</body>
<script type="text/javascript">
function change() {
var name = document.getElementById("name").value;
var url = "../ChaServlet?name=" + name;
if (confirm("确定要查询吗?")){
window.location.href = url;
}else{
return false;
}
}
</script>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Object test = request.getAttribute("test");
if(test!=null && !"".equals(test)){}
%>
<div><input type="text" id="name" name="name" value="${test.name}"></div>
<div><input type="button" value="保存" onclick="change('${test.name}')"></div>
</body>
<script type="text/javascript">
function change(name) {
var name1 = document.getElementById("name").value;
var url = "Change?name=" + name + "&name1=" + name1;
if (confirm("确定要修改吗?")){
window.location.href = url;
}else{
return false;
}
}
</script>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Object test = request.getAttribute("test");
if(test!=null && !"".equals(test)){}
%>
<div>${test.xuehao}</div>
<a href="index.html">返回主页面</a>
</body>
</html>
<%@ 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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
<title></title>
</head>
<%
//接收servlet传过来的那个message的参数
//alert是js语句中的弹出警示框,也就是弹出message中的参数
Object message=request.getAttribute("message");
if(!(message==null||message.equals("")))
{
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
request.setAttribute("message", null);
}
%>
<body>
<div align="center">
<h1 style="color: red;">信息总览</h1>
<table class="table table-hover table-striped table-bordered table-sm" id="resultshow">
<tr>
<td>角色名称</td>
<td>修改</td>
<td>删除</td>
</tr>
<c:forEach items="${test}" var="test">
<tr>
<td>${test.name}</td>
<td><a href="ChangeServlet?name=${test.name}">修改</a></td>
<td><a href="DeleteServlet?name=${test.name}">删除</a></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>