以表格格式呈现大量数据
我有一个网页,它显示从后端检索的大量数据(例如大约 1,000 个),并以正确的 HTML 表格格式显示,并具有正确的样式和内容。
现在我的问题是,我正在基于Java的Web环境上工作,因此为了显示这些数据负载,我使用JSP,并且从tomcat服务器返回时编译的JSP文件的大小以MB为单位。
我相信任何服务器端语言都可能出现这种情况(如果我错了,请纠正我)
我想知道的是,如果不是在 JSP 中制作整个表并在从 tomcat 返回时增加页面大小,而是使用JavaScript 在空白 HTML 页面中呈现表格格式,这是推荐的流程吗?
当我使用 JavaScript 时,对浏览器有什么影响?流程是否符合逻辑并值得推荐?
I have a webpage which displays loads of data (say around 1,000) retrieved from the back end and is displayed in a proper HTML table format with proper styling and stuff.
Now my question is, I am working on Java-based web environment, so in order to display this loads of data I use JSP and the compiled JSP file when returned from the tomcat server comes to size in MB's.
I believe this might be the case for any server-side-language (correct me if I am wrong)
What I want to know is, if instead of making the whole table in JSP and increasing my page size when returned from tomcat, I use JavaScript to render the tabular format in a blank HTML page, would this be a recommended flow?
What is the impact on the browser when I use JavaScript and is the flow logical and recommend one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想一次显示所有行,那么使用 Ajax 在页面加载后检索数据不会有任何大的优势。
一个小优点是您的服务器可以快速返回一个显示“正在加载”的小页面,然后使用 Ajax 进行加载。加载结束时,Javascript (JS) 将删除加载反馈。
如果您想在浏览器上对数据进行分页、使用户能够重新排列列、在本地对数据进行排序以及其他有趣的东西,您可以使用 JS 数据表小部件。有很多可供选择,我推荐 YUI Datatable 小部件。也是一个社区。
事实上,在我写这篇文章时,我正忙着向我的网站添加一个...
添加:
浏览器的影响通常是非物质性的。然而,当使用 JS 和精美的小部件时,浏览器怪癖往往会更频繁地发生。如果您对雅虎“A 级”浏览器列表感到满意,那么就没有问题。但如果你想支持任何随机浏览器,那么你应该坚持使用纯 html。
对于 JS 小部件,浏览器速度变得更加重要。我主动向 IE 用户发出警告,告诉他们如果改用 IE 替代方案,他们的工作效率会“更高”。 (我不是在谈论浏览器的速度,而是为用户提供了优势:更高的生产力。)
回复:Ajax 页面是推荐的流程吗?是的,这就是“Web 2.0”。纯 HTML 没有什么问题,但使用 Ajax 和数据表小部件可以为您的用户带来许多优势。
但您需要了解转换的成本/收益是否适合您和您的情况。
If you want to display all the rows at once, there wouldn't be any big advantages to using Ajax to retrieve the data after the page loaded.
A small advantage would be that your server could quickly return a small page that says "Loading" and then use Ajax to do the load. At the end of the load, the Javascript (JS) would remove the Loading feedback.
If you want to page your data on the browser, enable the user to re-arrange the columns, sort the data locally and other fun stuff, you could use a JS datatable widget. There are many to choose from, I recommend the YUI Datatable widget. A community too.
In fact, I'm busy adding one to my site as I write this...
Added:
Browser impact is usually non-material. However, browser quirks tend to occur more often when using JS and fancy widgets. If you're ok with the Yahoo "Grade A" browser list then you'll be fine. But if you want to support any random browser, then you should stick with plain html.
Browser speed becomes more important with JS widgets. I actively put up a warning to my IE users telling them that they'd be "much more productive" if they switched to an IE alternative. (Rather than talking about the speed of the browser, I give the advantage to the user: greater productivity.)
Re: Is an Ajax page a recommended flow? Yes, it's "Web 2.0." Nothing wrong with plain HTML, but using Ajax and a data table widget can bring your users many advantages.
But you'll need to see if the costs/benefits of switching are appropriate for you and your situation.