显示标签分页和排序的问题 [英] Display tag Issues with pagination and sorting

查看:168
本文介绍了显示标签分页和排序的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用display标签在我的应用程序中呈现表格。当我点击分页或排序时,它再次查询数据库然后排序/分页。在我看来,当我们只是排序/分页时,我们不需要查询数据库。

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:


  1. 我可以在会话中保留列表(从数据库中查询)并检查此请求是用于排序还是分页然后从会话中返回列表

  1. 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?

推荐答案

我过去一直在想这个问题,而且从我所看到的情况来看,如果您想使用库提供的分页/排序,您必须将数据存储在会话中的某个地方。它似乎没有提供一个方便的框架来执行客户端的操作,或者只是为了发布/返回相同的数据而存在一个虚拟的servlet。

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分页与Hibernate分页

显示标记分页问题

这篇关于显示标签分页和排序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆