我的html超链接在我的OSGI包中不起作用 [英] My html hyperlinks do not work in my OSGI bundle

查看:164
本文介绍了我的html超链接在我的OSGI包中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的OSGI包中使用Java和HelpGUI,并且使用的链接不起作用。当我在非OSGI Java项目中使用HelpGUI时,它们在相同的html文件上工作得很好。我需要考虑一些安全设置或特殊的路径吗?让我知道,我可怕地卡住了。

解决方案

你应该看看HelpGui的源代码,我可以看到为什么它在OSGi中并不完全适用(它依赖于jar文件中通常具有的特定URL格式资源)。



如果您查看net.sourceforge.helpgui。 gui.HelpView页面,在第222行左右:

 其他//这也许是一个关于帮助的页面toppic 
{
//将页面从
中分开int ind = url.lastIndexOf('!');
url = url.substring(ind + 1,url.length());
url = url.replaceFirst(MainFrame.helpPath +/,);
updatePage(getLinkedPage(pageRoot.children(),url),true);
}

这在OSGi中不起作用,因为条目的URL格式是真的不同。例如在Equinox中,一个包的URL如下所示:

  bundleresource://2.fwk1657006569:1general / features.html 

(其他实现可能不同,请注意,您不能依赖它)



在'普通java'中,URL如下所示:

  jar:file:/ home / demo-helpgui / nonosgi / lib / helpgui-1.1-demo.jar!/docs/help/general/features.html 

它是可以修复的,它不应该太难,但是您必须联系HelpGui作者或让自己的手变脏。



问候,弗兰克

I am using Java and HelpGUI in my OSGI bundle and the links that use do not work. When I use HelpGUI in a non-OSGI Java project, they work just fine on the same html files. Is there some security setting or something special with paths that I need to consider? Let me know, I am horribly stuck.

解决方案

You should have a look at the source code of HelpGui, I can see why it doesn't quite work in OSGi (it relies on a specific URL format resources in jar files usually have).

If you look at the net.sourceforge.helpgui.gui.HelpView page, around line 222:

else //It's perhaps a page on the help toppic
{
//Serach the page from  
int ind = url.lastIndexOf('!');
url = url.substring(ind+1,url.length());
url = url.replaceFirst(MainFrame.helpPath+"/","");
updatePage(getLinkedPage(pageRoot.children(), url), true);
}

That is not going to work in OSGi, as the URL format of entries is really different. For example in Equinox a bundle URL looks like:

bundleresource://2.fwk1657006569:1general/features.html

(Other implementations might be different, point is, you can't rely on it)

In 'normal java' the URL looks like:

jar:file:/home/demo-helpgui/nonosgi/lib/helpgui-1.1-demo.jar!/docs/help/general/features.html   

It is fixable, it shouldn't be too hard, but you'll have to either contact the HelpGui author or get your hands dirty yourself.

regards, Frank

这篇关于我的html超链接在我的OSGI包中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆