我需要在调用servlet时在客户端打开Java Swing应用程序。在客户端浏览器上通过JNLP打开的Swing应用程序的main方法中还需要接收一些参数。在我的例子中,swing应用程序正在打开,但无论如何都没有接收到参数。
我的JNLP文件没有动态构建。它是一个静态文件。
<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+"
codebase="http://localhost:8085/TestWebApp"
href="ContactEditor.jnlp">
<information>
<title>JNLP Example</title>
<vendor>Catalyst Software</vendor>
<homepage href="http://localhost:8085/TestWebApp" />
<description>JNLP Testing</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" />
<jar href="ContactEditor.jar" />
</resources>
<application-desc main-class="my.contacteditor.ContactEditorUI">
<argument>00001</argument>
<argument>Harish Prasad</argument>
<argument>220153429088</argument>
</application-desc>
<security>
<all-permissions/>
</security>
</jnlp>
请建议如何动态地从servlet传递参数到swing应用程序。
我的问题是:
- 我必须在我的Swing程序中写什么代码?
- 我必须在JNLP文件中提到什么?
- 我应该如何从servlet传递值?
-
JNLP文件语法指定"每个参数包含(按顺序)一个传递给
main
的附加参数"public static void main(String[] args) { for (String value : args) { … } }
-
您的
<argument>
语法看起来是正确的,如这里所述;<security>
元素出现两次,如图所示; -
您需要动态地构建JNLP文件,就像这里讨论的那样。