当前位置:Gxlcms > 数据库问题 > SQL前后端分页

SQL前后端分页

时间:2021-07-01 10:21:17 帮助过:16人阅读

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"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <a href="${pageContext.request.contextPath}/StudentServlet?method=getStuList&pageNo=1">go!</a> </body> </html> View Code

main.jsp

技术分享
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
</head>
<body>

    <table border="1" align="center" width="50%">
      <tr>
        <th>姓名</th>
        <th>学校</th>
        <th>成绩</th>
        <th colspan="2">操作</th>
      </tr>
      <c:forEach items="${page.data}" var="stu">
      <tr>
        <td>${stu.name}</td>
        <td>${stu.school}</td>
        <td>${stu.score}</td>
        <td> <a href="${pageContext.request.contextPath}/StudentServlet?method=toUpdatePage&id=${stu.id}">修改</a></td><!-- TOUpdate?id=${ stu.id}&name=${stu.name}&school=${stu.school}&score=${stu.score}之前用的方法 -->
        <td> <a href="${pageContext.request.contextPath}/StudentServlet?method=Delete&id=${stu.id}">删除</a></td>
      </tr>
      </c:forEach>
      <tr><td colspan="3" align="center"><a href="/Student-Sql/TOInsert">添加</a></td></tr>
    </table>   
    <br> 
    <%@ include file="/WEB-INF/view/paging.jsp" %>
</body>
</html>
View Code

insert.jsp

技术分享
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
   <form action="${pageContext.request.contextPath}/StudentServlet?method=Add" method="post">
                   姓名:<input type="text" name="name"/><br>
                   学校:<input type="text" name="school"/><br>
                    分数:<input type="text" name="score"/><br>
       <input type="submit" value="添加信息"/>
   </form>
</body>
</html>
View Code

update.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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <%-- <table border="1" align="center" width="50%" >
      <tr>
        <th>原信息</th>
        <th>新信息</th>        
      </tr>
      <c:forEach items="${student2}" var="stu">
      <form action="/Student-Sql/UpdateServlet?id=${stu.id}" method="post">
      <tr>
        <td>${stu.id}</td>
        <td>ID:${stu.id}</td>
      </tr>
       </c:forEach>
        <c:forEach items="${student2}" var="stu">
      <tr>
      
        <td>${stu.name}</td>
        <td>姓名:<input type="text" name="name"/></td>
      </tr>
      </c:forEach>
      <c:forEach items="${student2}" var="stu">
      <tr>       
        <td>${stu.school}</td>
        <td>学校:<input type="text" name="school"/></td>
      </tr>
      </c:forEach>
       <c:forEach items="${student2}" var="stu">
      <tr>
        <td>${stu.score}</td>
        <td>分数:<input type="text" name="score"/></td>
      </tr>      
      <tr><td>&nbsp;</td> <td><input type="submit" value="修改信息 "></td></tr>
    </c:forEach>
    </form>
    </table> --%>
    <form action="${pageContext.request.contextPath}/StudentServlet?method=Update&id=${stu.id}" method="post" >
    <%-- <input type="hidden" name="id" value="${stu.id}"/> --%>
         姓名:<input type="text" name="name" value="${stu.name}"/>
         学校:<input type="text" name="school" value="${stu.school}"/>
         分数:<input type="text" name="score" value="${stu.score}"/>
      <input type="submit" value="修改信息 ">
     </form>
</body>
</html>
View Code

paging.jsp

技术分享
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<div id="page_nav" align="center">
    <a href="${page.path}&pageNo=1">首页</a>
    <a href="${page.path}&pageNo=${page.pageNumber -1 }">上一页</a>
        <c:choose>
            <c:when test="${page.totalPage <= 5 }" >
                <c:set var="begin" value="1"></c:set>
                <c:set var="end" value="${page.totalPage}"></c:set>
            </c:when>
            <c:when test="${page.pageNumber <= 3 }">
                <c:set var="begin" value="1"></c:set>
                <c:set var="end" value="5"></c:set>
            </c:when>
            <c:otherwise>
                <c:set var="begin" value="${page.pageNumber-2}"></c:set>
                <c:set var="end" value="${page.pageNumber+2}"></c:set>
                <c:if test="${end > page.totalPage }">
                    <c:set var="begin" value="${page.totalPage-4}"></c:set>
                    <c:set var="end" value="${page.totalPage}"></c:set>
                </c:if>
            </c:otherwise>
        </c:choose>
        <c:forEach begin="${begin }" end="${end}" var="num">
            <c:if test="${page.pageNumber == num }">
                【${num}】
            </c:if>
            <c:if test="${page.pageNumber != num }">
                <a href="${page.path}&pageNo=${num}">${num }</a>
            </c:if>
        </c:forEach>
    <a href="${page.path}&pageNo=${page.pageNumber +1}">下一页</a>
    <a href="${page.path}&pageNo=${page.totalPage}">末页</a>
    共${page.totalPage }页,${page.totalRecord }条记录到,去第<input value="${page.totalPage }" name = "pn" id ="pn_input"/><input type="button" value="确定" id="btn_id"/>
    <script type="text/javascript">
        $("#btn_id").click(function(){
            var value= $("#pn_input").val();
            window.location="${page.path}&pageNo="+value;
        });
    </script>
</div>
View Code

最后。。导包

技术分享

SQL前后端分页

标签:第一个   character   empty   static   enter   uid   www.   修改   cti   

人气教程排行