課程
/后端開發(fā)
/Java
/Java 分頁原理與實踐(上)
who有sublistStudent.jsp的代碼嗎
2016-07-15
源自:Java 分頁原理與實踐(上) 4-5
正在回答
<%@ page language="java" contentType="text/html; charset=UTF-8"??? pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>學(xué)生信息</title></head><%?? ?// 獲取請求的上下文?? ?String context = request.getContextPath();%><script type="text/javascript">// 當(dāng)前第幾頁數(shù)據(jù)var currentPage = ${result.currentPage};// 總頁數(shù)var totalPage = ${result.totalPage};function submitForm(actionUrl){?? ?var formElement = document.getElementById("stuForm");?? ?formElement.action = actionUrl;?? ?formElement.submit();}// 第一頁function firstPage(){?? ?if(currentPage == 1){?? ??? ?alert("已經(jīng)是第一頁數(shù)據(jù)");?? ??? ?return false;?? ?}else{?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=1");?? ??? ?return true;?? ?}}// 下一頁function nextPage(){?? ?if(currentPage == totalPage){?? ??? ?alert("已經(jīng)是最后一頁數(shù)據(jù)");?? ??? ?return false;?? ?}else{?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=" + (currentPage+1));?? ??? ?return true;?? ?}}// 上一頁function previousPage(){?? ?if(currentPage == 1){?? ??? ?alert("已經(jīng)是第一頁數(shù)據(jù)");?? ??? ?return false;?? ?}else{?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=" + (currentPage-1));?? ??? ?return true;?? ?}}// 尾頁function lastPage(){?? ?if(currentPage == totalPage){?? ??? ?alert("已經(jīng)是最后一頁數(shù)據(jù)");?? ??? ?return false;?? ?}else{?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=${result.totalPage}");?? ??? ?return true;?? ?}}function initPage(){?? ?var genderRequest = "${gender}" ;?? ?var genderVal = 0;?? ?var genderElement = document.getElementById("gender");?? ?if(genderRequest != ""){?? ??? ?genderVal = parseInt(genderRequest);?? ?}?? ??? ?var options = genderElement.options;?? ?var i = 0;?? ?for(i = 0; i < options.length; i++){?? ??? ?if(options[i].value == genderVal){?? ??? ??? ?options[i].selected=true;?? ??? ??? ?break;?? ??? ?}?? ?}?? ?}</script><body onload="initPage();">?? ?<div style="margin-left: 100px; margin-top: 100px;">?? ??? ?<div>?? ??? ??? ?<font color="red">${errorMsg }</font>?? ??? ?</div>?? ??? ?<div>?? ??? ??? ?<form action="<%=context %>/sublist/SublistServlet"?? id="stuForm"? method="post">?? ??? ??? ??? ?姓名?? ??? ??? ??? ?<input type="text" name="stuName" id="stu_name" style="width:120px" value="${stuName }">?? ??? ??? ??? ? ?? ??? ??? ??? ?性別?? ??? ??? ??? ?<select name="gender" id="gender" style="width:80px">?? ??? ??? ??? ??? ?<option value="0">全部</option>?? ??? ??? ??? ??? ?<option value="1">男</option>?? ??? ??? ??? ??? ?<option value="2">女</option>?? ??? ??? ??? ?</select>?? ??? ??? ??? ? ?? ??? ??? ??? ?<input type="submit" value="查詢">?? ??? ??? ?</form>?? ??? ?</div>?? ??? ??? ??? ?<br>?? ??? ?學(xué)生信息列表:<br>?? ??? ?<br>?? ??? ?<!-- 后臺返回結(jié)果為空 -->?? ??? ?<c:if test="${fn:length(result.dataList) eq 0 }">?? ??? ??? ?<span>查詢的結(jié)果不存在</span>?? ??? ?</c:if>?? ??? ??? ??? ?<!-- 后臺返回結(jié)果不為空 -->?? ??? ?<c:if test="${fn:length(result.dataList) gt 0 }">?? ??? ??? ?<table border="1px" cellspacing="0px"?? ??? ??? ??? ?style="border-collapse: collapse">?? ??? ??? ??? ?<thead>?? ??? ??? ??? ??? ?<tr height="30">?? ??? ??? ??? ??? ??? ?<th width="130">姓名</th>?? ??? ??? ??? ??? ??? ?<th width="130">性別</th>?? ??? ??? ??? ??? ??? ?<th width="130">年齡</th>?? ??? ??? ??? ??? ??? ?<th width="190">家庭地址</th>?? ??? ??? ??? ??? ?</tr>?? ??? ??? ??? ?</thead>?? ??? ??? ??? ??? ?<c:forEach items="${result.dataList }" var="student">?? ??? ??? ??? ??? ??? ?<tr>?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.stuName }"></c:out></td>?? ??? ??? ??? ??? ??? ??? ?<td>?? ??? ??? ??? ??? ??? ??? ??? ?<c:if test="${ student.gender eq 1}">男</c:if>?? ??? ??? ??? ??? ??? ??? ??? ?<c:if test="${ student.gender eq 2}">女</c:if>?? ??? ??? ??? ??? ??? ??? ?</td>?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.age }"></c:out></td>?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.address }"></c:out></td>?? ??? ??? ??? ??? ??? ?</tr>?? ??? ??? ??? ??? ?</c:forEach>?? ??? ??? ?</table>?? ??? ??? ?<br> 共${result.totalRecord }條記錄共${result.totalPage }頁 當(dāng)前第${result.currentPage }頁 ?? ??? ??? ?<a href="#" onclick="firstPage();">首頁</a> ?? ??? ??? ?<a href="#" onclick="nextPage();">下一頁</a> ?? ??? ??? ?<a href="#" onclick="previousPage();">上一頁</a> ?? ??? ??? ?<a href="#" onblur="lastPage();">尾頁</a>?? ??? ??? ?</c:if>?? ?</div></body></html>
舉報
通過總結(jié)常見的分頁樣式,手把手帶你實現(xiàn)java常見的分頁功能
1 回答視頻的代碼
1 回答能提供代碼嗎
2 回答老師有代碼嗎?
1 回答項目有源代碼嗎
2 回答resultSet.getmetadata以及下面的代碼是什么意思
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-07-17
<%@ page language="java" contentType="text/html; charset=UTF-8"
??? pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>學(xué)生信息</title>
</head>
<%
?? ?// 獲取請求的上下文
?? ?String context = request.getContextPath();
%>
<script type="text/javascript">
// 當(dāng)前第幾頁數(shù)據(jù)
var currentPage = ${result.currentPage};
// 總頁數(shù)
var totalPage = ${result.totalPage};
function submitForm(actionUrl){
?? ?var formElement = document.getElementById("stuForm");
?? ?formElement.action = actionUrl;
?? ?formElement.submit();
}
// 第一頁
function firstPage(){
?? ?if(currentPage == 1){
?? ??? ?alert("已經(jīng)是第一頁數(shù)據(jù)");
?? ??? ?return false;
?? ?}else{
?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=1");
?? ??? ?return true;
?? ?}
}
// 下一頁
function nextPage(){
?? ?if(currentPage == totalPage){
?? ??? ?alert("已經(jīng)是最后一頁數(shù)據(jù)");
?? ??? ?return false;
?? ?}else{
?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=" + (currentPage+1));
?? ??? ?return true;
?? ?}
}
// 上一頁
function previousPage(){
?? ?if(currentPage == 1){
?? ??? ?alert("已經(jīng)是第一頁數(shù)據(jù)");
?? ??? ?return false;
?? ?}else{
?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=" + (currentPage-1));
?? ??? ?return true;
?? ?}
}
// 尾頁
function lastPage(){
?? ?if(currentPage == totalPage){
?? ??? ?alert("已經(jīng)是最后一頁數(shù)據(jù)");
?? ??? ?return false;
?? ?}else{
?? ??? ?submitForm("<%=context %>/sublist/SublistServlet?pageNum=${result.totalPage}");
?? ??? ?return true;
?? ?}
}
function initPage(){
?? ?var genderRequest = "${gender}" ;
?? ?var genderVal = 0;
?? ?var genderElement = document.getElementById("gender");
?? ?if(genderRequest != ""){
?? ??? ?genderVal = parseInt(genderRequest);
?? ?}
?? ?
?? ?var options = genderElement.options;
?? ?var i = 0;
?? ?for(i = 0; i < options.length; i++){
?? ??? ?if(options[i].value == genderVal){
?? ??? ??? ?options[i].selected=true;
?? ??? ??? ?break;
?? ??? ?}
?? ?}
?? ?
}
</script>
<body onload="initPage();">
?? ?<div style="margin-left: 100px; margin-top: 100px;">
?? ??? ?<div>
?? ??? ??? ?<font color="red">${errorMsg }</font>
?? ??? ?</div>
?? ??? ?<div>
?? ??? ??? ?<form action="<%=context %>/sublist/SublistServlet"?? id="stuForm"? method="post">
?? ??? ??? ??? ?姓名
?? ??? ??? ??? ?<input type="text" name="stuName" id="stu_name" style="width:120px" value="${stuName }">
?? ??? ??? ??? ?
?? ??? ??? ??? ?性別
?? ??? ??? ??? ?<select name="gender" id="gender" style="width:80px">
?? ??? ??? ??? ??? ?<option value="0">全部</option>
?? ??? ??? ??? ??? ?<option value="1">男</option>
?? ??? ??? ??? ??? ?<option value="2">女</option>
?? ??? ??? ??? ?</select>
?? ??? ??? ??? ?
?? ??? ??? ??? ?<input type="submit" value="查詢">
?? ??? ??? ?</form>
?? ??? ?</div>?? ??? ?
?? ??? ?<br>
?? ??? ?學(xué)生信息列表:<br>
?? ??? ?<br>
?? ??? ?<!-- 后臺返回結(jié)果為空 -->
?? ??? ?<c:if test="${fn:length(result.dataList) eq 0 }">
?? ??? ??? ?<span>查詢的結(jié)果不存在</span>
?? ??? ?</c:if>
?? ??? ?
?? ??? ?<!-- 后臺返回結(jié)果不為空 -->
?? ??? ?<c:if test="${fn:length(result.dataList) gt 0 }">
?? ??? ??? ?<table border="1px" cellspacing="0px"
?? ??? ??? ??? ?style="border-collapse: collapse">
?? ??? ??? ??? ?<thead>
?? ??? ??? ??? ??? ?<tr height="30">
?? ??? ??? ??? ??? ??? ?<th width="130">姓名</th>
?? ??? ??? ??? ??? ??? ?<th width="130">性別</th>
?? ??? ??? ??? ??? ??? ?<th width="130">年齡</th>
?? ??? ??? ??? ??? ??? ?<th width="190">家庭地址</th>
?? ??? ??? ??? ??? ?</tr>
?? ??? ??? ??? ?</thead>
?? ??? ??? ??? ??? ?<c:forEach items="${result.dataList }" var="student">
?? ??? ??? ??? ??? ??? ?<tr>
?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.stuName }"></c:out></td>
?? ??? ??? ??? ??? ??? ??? ?<td>
?? ??? ??? ??? ??? ??? ??? ??? ?<c:if test="${ student.gender eq 1}">男</c:if>
?? ??? ??? ??? ??? ??? ??? ??? ?<c:if test="${ student.gender eq 2}">女</c:if>
?? ??? ??? ??? ??? ??? ??? ?</td>
?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.age }"></c:out></td>
?? ??? ??? ??? ??? ??? ??? ?<td><c:out value="${student.address }"></c:out></td>
?? ??? ??? ??? ??? ??? ?</tr>
?? ??? ??? ??? ??? ?</c:forEach>
?? ??? ??? ?</table>
?? ??? ??? ?<br> 共${result.totalRecord }條記錄共${result.totalPage }頁 當(dāng)前第${result.currentPage }頁
?? ??? ??? ?<a href="#" onclick="firstPage();">首頁</a>
?? ??? ??? ?<a href="#" onclick="nextPage();">下一頁</a>
?? ??? ??? ?<a href="#" onclick="previousPage();">上一頁</a>
?? ??? ??? ?<a href="#" onblur="lastPage();">尾頁</a>?? ?
?? ??? ?</c:if>
?? ?</div>
</body>
</html>