从自定义URL处理程序获取参数

3

我创建了一个自定义的URL处理程序,成功地运行了我的Java应用程序(这是在Maven构建后生成的一个exe文件)。以下是我所做的步骤,并将处理程序添加到注册表中。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\my]
@="URL:my Protocol" 
"URL Protocol"=""

[HKEY_CLASSES_ROOT\my\shell]
@="open"

[HKEY_CLASSES_ROOT\my\shell\open\command]
@="\"C:\\myApp.exe\""

[HKEY_CLASSES_ROOT\my\shell\open\ddeexec]
@=""
"NoActivateHandler"=""

在我的test.html文件中,我有以下内容:

<a href="my:go/id=guest">My Application Start</a>

我如何在应用程序内部获取从URL传递的参数(链接中的id)?


1
所以请包含您的代码。 - user1907906
什么类型的处理程序? - digao_mb
你在用什么?Servlets吗? - Diogo Moreira
请将您的问题恢复到原始状态,并将您的解决方案作为答案添加。谢谢! - piet.t
1个回答

1
我用于注册的内容:
[HKEY_CLASSES_ROOT\myApp]
@="URL:myApp Protocol handled by CustomURL"
"URL Protocol"=""
"CustomUrlApplication"="C:\\temp\\eclipse.exe"

[HKEY_CLASSES_ROOT\myApp\DefaultIcon]
@="C:\\temp\\eclipse.exe"

[HKEY_CLASSES_ROOT\myApp\shell]

[HKEY_CLASSES_ROOT\myApp\shell\open]

[HKEY_CLASSES_ROOT\myApp\shell\open\command]
@="C:\\temp\\eclipse.exe %1"

我的HTML文件中的链接看起来像这样:

<a href="myApp:go/USER">Application Start</a>

然后我可以通过以下方式在我的应用程序中获取完整链接:
String[] args = Platform.getCommandLineArgs();

这肯定节省了我很多时间来交付完全相同的解决方案。但是,你能用哪个maven构建原型生成*.exe文件呢?或者,等一下,这是一个Eclipse RPC应用程序吗? - swdev
1
这是一个Eclipse RPC应用程序。 - Mahsa

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接