无需刷新网页即可显示图像流,为用户提供类似视频的体验
我在 servlet 中生成了一系列图像。我想在 JSP 页面上显示图像。 我想以一种 JSP 页面不刷新、仅图像刷新并被新图像替换的方式显示图像。我想到借助小程序或AJAX 来完成。但我仍在寻找一些方便的方法来做到这一点。谁能建议一些方法吗?非常感谢任何帮助。
提前致谢。
I have a series of images generated at the servlet. I want to show the images on a JSP page.
I want to show the images in a way that the JSP page is not refreshed only the image gets refreshed and get replaced by the new one. I thought of doing it with the help of applet or AJAX. But I am still looking for some convenient way of doing it. can anyone suggest some way of doing it? Any help is much appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我是你,我会选择 JavaScript。拥有一个图像列表并设置一个计时器来每秒更改图像标签的源(或其他)应该非常简单。您可能甚至不需要“真正的”AJAX...只需更改 DOM 中的属性即可。
诚然,如果图像需要一段时间才能加载,那么看起来可能不太好 - 您可能希望有一些巧妙的机制来预先加载所有图像,然后随时更改哪个图像可见,或者类似的事情。但它仍然不需要 AJAX 或小程序。
我不确定我是否会将其描述为“类似视频”的体验 - 更像是幻灯片 - 但应该没问题。如果您想要真实视频,请使用视频:)
I'd go with JavaScript if I were you. It should be pretty simple to have a list of images and set a timer to change the source of the image tag every second (or whatever). You probably don't even need "real" AJAX for that... just changing the attributes in the DOM.
Admittedly it may not look great if the images take a while to load - you might want to have some cunning mechanism to load all the images beforehand, and then change which one is visible at any one time, or something like that. It still shouldn't need AJAX or an applet though.
I'm not sure I'd describe this as a "video-like" experience - more like a slide-show - but it should be okay. If you want real video, use video :)
有很多简单的 jQuery 图像幻灯片库可以轻松添加到您的页面中,并且可以添加一些很棒的效果 - 例如:
http://nivo.dev7studios.com/#usage
There are a lot of simple jQuery image slideshow libraries that are easily added to your page and can add some great effects - for example:
http://nivo.dev7studios.com/#usage