是否可以使用 Flying Saucer (XHTML-Renderer) 将 css 解析为类路径资源?
我正在尝试将资源打包到 jar 中,但我无法让 Flying Saucer 在类路径上找到 css - 我无法轻松构造 URL 来无缝解决此问题。
飞碟是否有办法在类路径上指定资源包来解析项目和图像?
注意:我在一个没有文件系统写入权限的 webstart 应用程序中运行它,因此 jar 扩展并不是真正的选择。
I'm trying to package up resources into a jar, but I'm having trouble getting Flying Saucer to find the css on the classpath - I can't construct a URL easily to be able to resolve this seamlessly.
Does Flying saucer have a way of specifying resource packages on the classpath to resolve items and images?
Note: I'm running this in a webstart application that does not have file system writing permissions, so jar expansion is not really an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该实现一个 UserAgentCallback 并将其提供给 XHTMLPanel,如下所示:
You should implement a UserAgentCallback that you feed to the XHTMLPanel, something like this:
我的解决方案是
调用:
My solution is
and invocation:
飞碟似乎没有办法在类路径上指定资源,因此我通过制作 classpath: 链接问题的协议 url 处理程序
实施后的发现
这个问题的一些前提似乎是无效的。在编写自己的类路径 URL 加载器后,我发现需要在 jnlp 中请求
才能使用URL.setURLStreamHandlerFactory()
。事实上,您需要请求所有权限才能执行任何奇特的操作(即使您只是修改自己的沙箱)。请参阅此处的完整列表。简而言之,这意味着我能够将文件提取到操作系统。但现在有一个类路径加载器真是太好了......
It would seem that flying saucer does not have a way of specifying resources on the classpath, so I work around by making a classpath: protocol url handler at the linked question
Post Implementation Findings
It would seem that the some of the premises of this question are invalid. After writing my own classpath URL loader, I found that you need to request
<all-permissions/>
in the jnlp to be able to useURL.setURLStreamHandlerFactory()
. In fact, you need to request all permissions to do just about anything fancy (even though you're only modifying your own sand-box). See the full list here.In short, this means that I am able to extract files to the operating system. But it's nice having a classpath loader now...