如何在 Wicket 中动态快速加载图像?
我正在尝试使用 Wicket WebResource
同时动态加载大量图像。问题是加载它们需要很长时间,在某些情况下需要一分钟以上,然后我收到以下错误:
org.apache.wicket.protocol.http.request.InvalidUrlException:org.apache.wicket.WicketRuntimeException:1分钟后,Pagemap null仍被:Thread[http-8443-2,5,main]锁定,给出尝试获取路径页面: 6:documentList:scroller:batchElem:11:content:item:7:cols:9:batchItemContent:linkToPreview:imageThumbnail
在 org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)
在 org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
在 org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
在 org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
有谁知道其他解决方案来动态加载图像,以避免错误?
I am trying to load a lot of images at the same time, dynamically, using a Wicket WebResource
. The problem is that it takes a lot of time to load them, and in some cases it takes more than a minute, and then I get the following error:
org.apache.wicket.protocol.http.request.InvalidUrlException: org.apache.wicket.WicketRuntimeException: After 1 minute the Pagemap null is still locked by: Thread[http-8443-2,5,main], giving up trying to get the page for path: 6:documentList:scroller:batchElem:11:content:item:7:cols:9:batchItemContent:linkToPreview:imageThumbnail
at org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
Does anyone know other solutions to load an image dynamically, in order to avoid the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将每个图像放入
AjaxLazyLoadPanel
中,然后它会为每个图像向服务器创建许多简短的请求。You could put each of the images in an
AjaxLazyLoadPanel
which would then create many short requests to the server for each image.您当然应该尝试让加载时间少于一分钟,这样您就不会遇到页面映射锁定异常这样您就不会让用户等待。
可以增加超时,(请参阅这个问题)但这不是最好的解决方案。
什么事要花这么多时间?您正在进行复杂的动态图像渲染吗?你能显示代码吗?
您可能已经意识到这一点,但是有图像示例可能有用。
You should certainly try to get the load to take less than a minute, so you don't get the pagemap lock exception and so that you don't keep your users waiting.
The timeout can be increased, (see this question ) but that's not the best solution.
What is taking this much time? Are you doing complex rendering of dynamic images? Can you show code?
You're probably already aware of it, but there are image examples that might be useful.
更好地利用Wicket共享资源来传递图像内容。
即类似:
在 MyApp#init() 中挂载资源 - mountSharedResource()(1.4)或 mountResource()(1.5)。
然后使用 ContextImage 和指向已安装资源的 url + 带有图像名称/路径的动态参数。
好处是 Wicket 共享资源不会同步为 Wicket 页面。
Better use Wicket shared resources to deliver the image content.
I.e. something like:
in MyApp#init() mount the resource - mountSharedResource() for 1.4 or mountResource() for 1.5.
Then use ContextImage with url that points to the mounted resource + dynamic parameter with the image name/path.
The benefit is that Wicket shared resources are not synchronized as Wicket Pages.