从Java的Desktop.getDesktop().browse(URI uri);设置查询字符串. [英] Setting a query string from Java's Desktop.getDesktop().browse(URI uri);

查看:75
本文介绍了从Java的Desktop.getDesktop().browse(URI uri);设置查询字符串.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Google谷歌搜索,但找不到答案.我正在编写一个纯Java桌面应用程序.通过使用Desktop类浏览功能并为其提供URI,可以启动帮助系统.当我添加?"时,Java中的URI失败.我想将程序版本号传递到浏览器中的脱机帮助页面,但是我不知道如何设置查询字符串.

I have tried googling but I cannot find an answer. I am writing a pure Java Desktop application. The help system launches by using the Desktop class browse function and giving it a URI. When I add a "? then the URI fails in Java. I want to pass the program version number to my offline help page in the browser, but I cannot figure out how to set a query string.

我正在RedHat 6上运行.我正在使用以下代码:

I am running on RedHat 6. I am using this code:

uri = new URI("file", "", programPath, "version=1.0.3", "");
Desktop.getDesktop().browse(uri);

我在浏览功能上得到一个IOException.它只说无法显示URI:"

I get an IOException on the browse function. All it says is that "Failed to show URI:"

如果我使用完整的uri路径并将其粘贴到我的浏览器中,它将起作用.我对此深感困惑……

If I take that full uri path and paste it in my browser, it works. I am completely stumped by this...

推荐答案

好的,所以我从来没有像我想要的那样工作,但是如果我使用只接受字符串的URI构造函数,然后将路径作为正常,总是可以正常工作,然后添加#+ versionNumberVar";然后就可以了!这很令人沮丧,因为它不能与?version =" + versionNumberVar一起使用,但是我终于有了我需要的东西.而且,那些其他构造函数对我不起作用,这令人惊讶.不幸的是,URI错误消息是含糊的,并且只显示无法显示URI".

Okay so I never got it working the way I wanted to, but if I use the URI constructor that just takes a string and then I feed it the path as normal which always worked and then add "# + versionNumberVar"; then it works! It is frustrating because it won't work with "?version=" + versionNumberVar but I have what I need finally. Also, those other constructors do not work for me which is surprising. Unfortunately the URI error messages are cryptic and it just says "Failed to show URI".

这篇关于从Java的Desktop.getDesktop().browse(URI uri);设置查询字符串.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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