后台数据在前台页面显示时实现分页

Dao层代码
public interface AttachmentDao {

    List<AttachmentExtends> selectAttachmentList();
}
Service层代码
@Service
public class AttachmentServiceImp implements AttachmentService {
    @Autowired
    private AttachmentDao attachmentDao;
    //查询所有的附件
    @Override
    public PageInfo<AttachmentExtends> queryAttachmentList(int currentPage) throws Exception {
        PageHelper.startPage(currentPage,3);
        List<AttachmentExtends> list = attachmentDao.selectAttachmentList();
        PageInfo<AttachmentExtends> pageInfo = new PageInfo<>(list,5);
        return pageInfo;
    }
}
public interface AttachmentService {
    PageInfo<AttachmentExtends> queryAttachmentList(int currentPage)throws Exception;
}

Controller层代码
@Controller
@RequestMapping("/atta")
public class AttachmentController {
    @Autowired
    private AttachmentService attachmentService;
    //查询后台数据库的所有附件
    @RequestMapping("/attachment-show")
    public String attachmentShow(Model model,@RequestParam(defaultValue = "1") int currentPage)throws Exception{
        PageInfo<AttachmentExtends> pageInfo = attachmentService.queryAttachmentList(currentPage);
        model.addAttribute("pageInfo",pageInfo);
        return "../project-file.jsp";
    }
}
前端数据的显示及前端分页的代码
<c:forEach items="${pageInfo.list}" var="att" varStatus="xxoo">
	<tr align='center' bgcolor="#FFFFFF" 		onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
	    <td><input name="id" type="checkbox" id="id" value="101" class="np"></td>
		<td>${xxoo.count}</td>
		<td>${att.attname}</td>
		<td align="center"><a href=''><u>${att.projectExtends.pname}</u></a></td>
		<td><fmt:formatDate value="<%= new Date() %>" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate> </td>
		<td><fmt:formatDate value="<%= new Date() %>" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
		<td><a href="${pageContext.request.contextPath}/attachment/download?path=${att.path}">下载</a> |<a href="#">删除</a> |<a href="project-file-edit.jsp">编辑</a> | <a href="project-file-look.jsp">查看详情</a></td>
	</tr>
</c:forEach>
页码部分
<tr align="right" bgcolor="#EEF4EA">
	<td height="36" colspan="12" align="center">
        <!--翻页代码 -->
        <a href="javascript:pageFun(1)">首页</a>
        <a href="javascript:pageFun(${pageInfo.prePage})">上一页</a>
        【
        <c:forEach items="${pageInfo.navigatepageNums}" var="num">
            <c:choose>
                <c:when test="${pageInfo.pageNum == num}">
                    <a href="javascript:pageFun(${num})" style="color: red;">${num}</a>
                </c:when>
                <c:otherwise>
                    <a href="javascript:pageFun(${num})">${num}</a>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        】
        <a href="javascript:pageFun(${pageInfo.nextPage})">下一页</a>
        <a href="javascript:pageFun(${pageInfo.pages})">尾页</a>
    </td>
</tr>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值