JavaEE中显示标签如何渲染数据?

发布于 2024-11-18 21:09:00 字数 142 浏览 3 评论 0原文

从我开始使用 JavaEE 开始,我就在 .jsp 中对列表进行分页,但我看到许多 Java 开发人员都在使用显示标签库,为什么,我不知道,因为我知道显示标签库获取页面中的整个列表,然后才会处理它,如果数据库中仍然有数千个条目?那又怎样呢?最后这个库的缺点和优点是什么?

From the time I started working with JavaEE, I've made ​​my way paginating a list in the .jsp, but I have seen many of Java developers are using display tag library, why, I don't know, as I know display tag library gets the whole list in the page, and only then will process it, and if you still have thousands of entries in the database? what about that? and finally what are the cons and pros of this library?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甲如呢乙后呢 2024-11-25 21:09:00

该标签与您提供的结果列表一起使用。它可以是一个页面的结果,也可以是分成多个页面的整个列表的结果。它并不是偶然被称为显示标签,它实际上显示您提供的数据。

如果数据库中有数千个条目,那么管理它们就是您的工作,而不是标签的工作。显示标签只是一个工具。您可以使用它或寻找其他工具。

最后这个库的缺点和优点是什么?

显示标签(实际上是任何服务器标签)用于限制您必须自己编写的样板代码数量才能完成工作。

按照您的方式编写代码,然后使用显示标记编写代码。哪一个更短?显示标签将是。

如果您在满月时编写一次分页表,您不会真正看到好处,但如果您编写大量表,那么在某个时刻时间将开始增加。使用库意味着要编写的样板代码更少,而且加起来也不会那么多(即编写速度更快)。

该标签引入的另一件重要的事情是一致性。如果所有开发人员都使用显示标签,那么所有人都可以轻松地处理彼此的代码。相信我,我使用过显示标签和不使用显示标签。没有它,那是一片丛林。每个开发人员都有自己的风格来创建分页、管理服务器上的交互、到处都是脚本......这太疯狂了!

我并不是说它是分页表的圣杯(例如,尽管我有很多表格要显示,但我不会在我的一个宠物项目中使用它。但我确实有自己的自定义标签,专门为我的特定目的而设计这给我带来了速度和一致性)。

您不必使用显示标签,但它是一个非常好的库,也有很多配置。因此,在做出决定之前,请尝试阅读其文档

The tag works with the list of result you give it. It can be results for a page or the entire list which it splits in multiple pages. It is not called a display tag by chance, it actually displays the data you provide it with.

If you have thousands of entries in the database its your job to manage them, not the tag's. The display tag is just a tool. You can use it or look for another tool.

And finally what are the cons and pros of this library?

The display tag (any server tag actually) is used to limit the amount of boiler plate code you have to write for yourself in order to get the job done.

Write the code your way, then write the code using the display tag. Which one is shorter? The display tag’s will be.

If you write a paginating table once in a full moon you don’t really see the benefit, but if you write lots of tables then at some point the time will start to add up. The library use means less boilerplate code to write and it doesn’t add up as much (i.e. it’s faster to write).

One other important thing the tag introduces is consistency. If all the developers use the display tag then all will have an easy time working on each other’s code. Trust me, I have worked with both the display tag and with no display tag. It was a jungle without it. Every developer had its style of creating the pagination, managing interactions at the server, scriptlets all around... it was crazy!

I’m not saying it’s the Holly Grail of paginating tables (for example I don’t use it in one of my pet projects although I have lots of tables to display. But I do have my own custom tag especially designed for my specific purposes which brings me the speed and consistency).

You are not obliged to use the display tag but it is a pretty good library, lots of configurations too. So try reading it’s documentation before making a decision.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文