jsp

addUser.jsp
<%@ 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 action="${pageContext.request.contextPath}/user/addUser" method="post">
		姓名:<input type="text" name="sname"/>
		年龄:<input type="text" name="age"/>
		<input type="submit" value="提交"/>
	</form>
</body>
erro.jsp
<%@ 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>
操作错误!
</body>
</html>
updateUser.jsp
<%@ 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>
<form action="${pageContext.request.contextPath}/user/updateUser" method="post">
	<input type="text" value="${user.sno}" name="sno" readonly="readonly"/></br>
	<input type="text" value="${user.sname}" name="sname"/></br>
	<input type="text" value="${user.age}" name="age" />
	<input type="submit" value="提交" />
</form>
</body>
</html>
userinfo.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="${pageContext.request.contextPath}/user/queryByUname"
		method="post">
		<input type="text" name="sname" placeholder="请输入姓名关键字进行搜索" /> <input
			type="submit" value="提交" />
			<a href="${pageContext.request.contextPath}/user/toAddUser">添加</a>
	</form>
	<table border="1">
		<tr>
			<td>学号</td>
			<td>姓名</td>
			<td>年龄</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${ulist}" var="x">
			<tr>
				<td>${x.sno}</td>
				<td>${x.sname}</td>
				<td>${x.age}</td>
				<td><a href="${pageContext.request.contextPath}/user/update?sno=${x.sno}">修改/</a><a href="javascript:del(${x.sno})">删除</a></td>
			</tr>
		</c:forEach>
	</table>
	第${pageinfo.pageNum}页/共${pageinfo.pages}页

	<c:choose>
		<c:when test="${flag==1}">
			<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>
		</c:when>
		<c:otherwise>
			<a
				href="${pageContext.request.contextPath}/user/queryByUname?pageNum=${pageinfo.prePage}&sname=${sname}">上一页</a>
			<c:forEach begin="1" end="${pageinfo.pages}" step="1" var="y">
				<a
					href="${pageContext.request.contextPath }/user/queryByUname?pageNum=${y}&sname=${sname}">${y}</a>
			</c:forEach>
			<a
				href="${pageContext.request.contextPath }/user/queryByUname?pageNum=${pageinfo.nextPage}&sname=${sname}">下一页</a>

		</c:otherwise>
	</c:choose>
</body>

<script >
	function del(sno){
		if(window.confirm("确定要删除吗?")){
			//console.log("跳转");
			//window.open();
			
			window.location.href="${pageContext.request.contextPath}/user/delUser?sno="+sno;
		}else{
			console.log();
		}
	}
</script>
</html>


 

更多推荐

java ee jsp