一、今日学习内容:添加提示信息

在考试前的最后阶段,还是要看一些自己不熟悉的知识:

在删除和修改之后都会跳转到 userlist.jsp 界面,显示提示信息。前面在介绍“添加用户”
188 Java Web 程序设计基础教程
功能的时候,也在 userlist.jsp 中添加了提示信息。实际上,现在需要的提示信息和前面的提
示信息是相同的,所以不需要再编写代码,而可以直接使用原来的代码,只要保证在 request
中存储信息时所用的名字是“info”即可。

<%@ page contentType="text/html;charset=gb2312"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script language="javascript">
function init(){
alert("${info}");
}
<c:if test="${!empty info}">
window.onload=init;
</c:if>
</script>
<h2 align=center>所有用户信息<h2>
<font size=4>
共有${pageCount}页,这是第${pageNo}页。
<!--如果是第一页,则不显示超链接-->
<c:if test="${pageNo==1}">
第一页
上一页
</c:if>
<!--如果不是第一页,则显示超链接-->
<c:if test="${pageNo!=1}">
<a href="findAllUser?pageNo=1">第一页</a>
<a href="findAllUser?pageNo=${pageNo-1}">上一页</a>
</c:if>
<!--如果是最后一页,则不显示超链接-->
<c:if test="${pageNo==pageCount}">
下一页
最后一页
</c:if>
<!--如果不是最后一页,则显示超链接-->
<c:if test="${pageNo!=pageCount}">
<a href="findAllUser?pageNo=${pageNo+1}">下一页</a>10 章 修 改 和 删 除 189
<a href="findAllUser?pageNo=${pageCount}">最后一页</a>
</c:if>
<form action="findAllUser">
跳转到<input type="text" name="pageNo">页<input type="submit" value="跳转">
</form>
</font>
<table align=center>
<tr>
<th>用户编号</th>
<th>用户名</th>
<th>用户类型</th>
<th>生日</th>
<th>学历</th>
<th>地区</th>
<th>Email</th>
<th>地址</th>
<th>修改</th>
<th>删除</th>
</tr>
<c:forEach items="${userlist}" var="user" >
<tr>
<td>${user.userid}</td>
<td>${user.username}</td>
<td>
<c:if test="${user.type==0}">普通用户</c:if>
<c:if test="${user.type==1}">管理员</c:if>
</td>
<td>${user.birthday}</td>
<td>${user.degree}</td>
<td>${user.local}</td>
<td>${user.email}</td>
<td>${user.address}</td>
<td>
<form action="updateFindUser" method="post">
<input type="submit" value="修改">
<input type="hidden" name="userid" value="${user.userid}">
</form>
</td>
<td>
<form action="deleteUser" method="post"
onSubmit="return confirm('真的要删除该用户吗?');">
<input type="hidden" name="userid" value="${user.userid}">
<input type="submit" value="删除">
</form>
</td>
</tr>
</c:forEach>
</table>

明天期末,测试类自己的数据库连接等问题,增删改查等等:

 

posted on 2020-12-19 20:40  白日梦想家~  阅读(98)  评论(0编辑  收藏  举报