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

本文介绍了一个基于分层架构的文件管理系统实现,包括Dao层的数据库操作接口、Service层的业务逻辑处理以及Controller层的请求响应处理。系统通过PageHelper进行分页查询,返回PageInfo对象给前端展示。

Dao层代码
public interface AttachmentDao {

List<AttachmentExtends> selectAttachmentList();

}
Service层代码
@Service
public class AttachmentServiceImp implements AttachmentService {
@Autowired
private AttachmentDao attachmentDao;
//查询所有的附件
@Override
public PageInfo queryAttachmentList(int currentPage) throws Exception {
PageHelper.startPage(currentPage,3);
List list = attachmentDao.selectAttachmentList();
PageInfo pageInfo = new PageInfo<>(list,5);
return pageInfo;
}
}
public interface AttachmentService {
PageInfo 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 pageInfo = attachmentService.queryAttachmentList(currentPage);
model.addAttribute(“pageInfo”,pageInfo);
return “…/project-file.jsp”;
}
}
前端数据的显示及前端分页的代码
<c:forEach items="KaTeX parse error: Expected 'EOF', got '#' at position 75: …nter' bgcolor="#̲FFFFFF" onMou…{xxoo.count}
a t t . a t t n a m e &lt; / t d &gt; &lt; t d a l i g n = &quot; c e n t e r &quot; &gt; &lt; a h r e f = ′ ′ &gt; &lt; u &gt; {att.attname}&lt;/td&gt; &lt;td align=&quot;center&quot;&gt;&lt;a href=&#x27;&#x27;&gt;&lt;u&gt; att.attname</td><tdalign="center"><ahref=><u>{att.projectExtends.pname}
<fmt:formatDate value="<%= new Date() %>" pattern=“yyyy-MM-dd HH:mm:ss”></fmt:formatDate>
<fmt:formatDate value="<%= new Date() %>" pattern=“yyyy-MM-dd HH:mm:ss”></fmt:formatDate>
下载 |删除 |编辑 | 查看详情

</c:forEach>
页码部分

首页 上一页 【 ${num} ${num} 】 下一页 尾页
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值