显示标签分页和排序问题
我正在使用显示标签来呈现应用程序中的表格。当我单击分页或排序时,它会再次查询数据库,然后排序/分页。在我看来,当我们只是排序/分页时,我们不需要查询数据库。
我看到以下选项可以解决此问题:
我可以将列表(从数据库查询)保留在会话中,并检查此请求是否用于排序或分页,然后从会话返回列表
或者我可以维护一个服务器端缓存,其工作方式与上面相同
如果我遗漏了一些东西,请纠正我,我认为这个功能应该已经在显示标签库中了?
I am using display tag to render tables in my application. When I click either pagination or sorting, it's querying the database again and then sorting/paging. In my opinion, when we are only sorting/paging, we need not query database.
I see following options to tackle this:
I can keep the list (queried from the db) in the session and check it this request is for sorting or pagination then return the list from the session
Or I can maintain a server side cache which will work the same as above
Please correct me if I am missing something I think this functionality should already have been in the display tag library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我过去曾想过这个问题,从我所看到的来看,如果您想使用库提供的分页/排序,则必须将数据存储在会话之类的地方,这是正确的。它似乎没有提供一个方便的框架来执行客户端操作,也没有提供一个虚拟 servlet,只是为了发布/返回相同的数据。
您的替代方法是使用带有部分列表的外部分页/排序。这需要您访问数据库,但您可以返回比整个结果集更小的数据量。
以下是一些相关的帖子,它们似乎暗示着相同的结论:
DisplayTag 分页与 Hibernate分页
显示标记分页问题
I have wondered about this in the past, and from what I've seen, you're on the right track with having to store the data somewhere like the session if you want to use the library-provided pagination/sorting. It doesn't seem to provide a convenient framework to do the actions client-side, or a dummy servlet to that exists just to post/return the same data.
Your alternative is to use external pagination/sorting with a partial list. This requires you to go to the database, but you can return a smaller amount of data than the entire result set.
Here are a couple related posts which seem to imply the same conclusions:
DisplayTag pagination vs Hibernate Pagination
Display tag pagination problem