jsp分页显示数据库数据怎么写代码?

2019-02-13 10:52发布

问题:

q前后端传参使用的是Model.

层次结构分别是:DAO层-Service层-controller层

页面使用的是jsp,查询数据使用的是el

框架是SSM

回答1:

我记得有个插件分页插件,后端你搜一下记不住了就是针对ssm的,我找了一下是

    <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper</artifactId>
            <version>5.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.3</version>
        </dependency>

这个



回答2:

后端Controll返回值到Jsp页面,使用Model存储参数,El直接$获取。



回答3:

<c:if test="${not empty page.totalPageCount}">
<div class="pager" align="center">
<font size="2">共 ${page.totalPageCount} 页</font> <font size="2">第
${page.pageNow} 页</font> <a href="handle_limit?pageNow=1">首页</a>
<c:choose>
<c:when test="${page.pageNow - 1 > 0}">
<a href="handle_limit?pageNow=${page.pageNow - 1}">上一页</a>
</c:when>
<c:when test="${page.pageNow - 1 <= 0}">
<a href="handle_limit??pageNow=1">上一页</a>
</c:when>
</c:choose>
<c:choose>
<c:when test="${page.totalPageCount==0}">
<a href="handle_limit?pageNow=${page.pageNow}">下一页</a>
</c:when>
<c:when test="${page.pageNow + 1 < page.totalPageCount}">
<a href="handle_limit?pageNow=${page.pageNow + 1}">下一页</a>
</c:when>
<c:when test="${page.pageNow + 1 >= page.totalPageCount}">
<a href="handle_limit?pageNow=${page.totalPageCount}">下一页</a>
</c:when>
</c:choose>
<c:choose>
<c:when test="${page.totalPageCount==0}">
<a href="handle_limit?pageNow=${page.pageNow}">尾页</a>
</c:when>
<c:otherwise>
<a href="handle_limit?pageNow=${page.totalPageCount}">尾页</a>
</c:otherwise>
</c:choose>
</div>
</c:if>

 



标签: ssm jsp 分页