jsp页面
userinfo.jsp
<%@ 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>UserInfo</title>
<style type="text/css">
body{
text-align: center;
}
</style>
</head>
<body>
<form method="post" action="${pageContext.request.contextPath}/user/queryByName">
<input type="text" name="uname" />
<input type="submit" value="查询" />
<a href="${pageContext.request.contextPath}/user/toAddUser">添加</a><br><br>
<table border="1" style="margin: auto;width:500px">
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>操作</th>
</tr>
<c:forEach items="${ulist}" var="x">
<tr>
<td>${x.uid}</td>
<td>${x.uname}</td>
<td>${x.age}</td>
<td>
<a href="${pageContext.request.contextPath}/user/toUpdtUser?uid=${x.uid}">修改</a>
<!-- <a href="${pageContext.request.contextPath}/user/delUser?uid=${x.uid}">删除</a> -->
<a href="javascript:del(${x.uid})">删除</a>
</td>
</tr>
</c:forEach>
</table><br>
</form>
第${pageinfo.pageNum}页/共${pageinfo.pages}页
<a href="${pageContext.request.contextPath}/user/getAllUser?pageNum=${pageinfo.prePage}">上一页</a>
<c:forEach begin="1" end="${pageinfo.pages}" step="1" var="y">
<a href="${pageContext.request.contextPath}/user/getAllUser?pageNum=${y}">${y}</a>
</c:forEach>
<a href="${pageContext.request.contextPath}/user/getAllUser?pageNum=${pageinfo.nextPage}">下一页</a>
</body>
<script>
function del(uid) {
if (window.confirm("确定删除?")) {
console.log("delete");
//window.open();
window.location.href = "${pageContext.request.contextPath}/user/delUser?uid=" + uid;
} else {
console.log("no action");
}
}
</script>
</html>
update.jsp
<body>
<h1>修改用户</h1>
<form method="post" action="${pageContext.request.contextPath}/user/updtUser">
编号:<input type="text" name="uid" value="${user.uid}" readonly="readonly"><br><br>
姓名:<input type="text" name="uname" value="${user.uname}"><br><br>
年龄:<input type="text" name="age" value="${user.age}"><br><br>
<input type="submit" value="修改">
</form>
</body>