我可以将复杂的参数传递给 Java Applet 吗?
我对 Java 很陌生,我必须创建一个用于电子签名文档的小程序。该小程序将从 ASP.Net 网页应用程序调用。
现在,我将小程序作为
<PARAM id="EdocPath" NAME="EdocPath" value="\\some\where\file.txt" />
在小程序中,我可以使用小程序的内置方法 getParameter("EdocPath")
获取值;
我需要的是能够向小程序传递多个文件及其“显示名称”的列表。例如,像 XML 字符串一样写下来很简单:
<DocumentList>
<UnsignedDocument Path="\\some\wehere\file1.txt" Description="Whatever comes here" />
<UnsignedDocument Path="\\some\wehere\file2.txt" Description="Something else" />
...
但是,据我在 HTML4.01 规范,PARAM
HTML 元素可能没有内容,也没有结束标记。
我正在考虑的选择是:
- 对 xml 结构进行 html 编码,并将其发送到单个 PARAM 对象中的小程序
- 创建 PARAM 对象列表并构造它们的名称,如“File1”、“Description1”、“File2”、“Description2” ", "File3"...然后在 Java 小程序中创建一个 while 循环来读取文件名。
然而,这些解决方案似乎都不是优雅的。问题是,这种情况下的最佳做法是什么?
I'm really new to Java and I have to create an applet for signing documents electronically. The applet will be called from an ASP.Net web page application.
Right now, I embed the applet in page as a <object id="EDOCApplet" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">
and send parameters to the applet like this:
<PARAM id="EdocPath" NAME="EdocPath" value="\\some\where\file.txt" />
In the applet, I can get the value using applet's built-in method getParameter("EdocPath")
;
What I need is the ability to pass the applet a list of several files and their "display names". For instance, it would be simple to write it down like an XML string:
<DocumentList>
<UnsignedDocument Path="\\some\wehere\file1.txt" Description="Whatever comes here" />
<UnsignedDocument Path="\\some\wehere\file2.txt" Description="Something else" />
...
However, as far as I see in HTML4.01 specification, the PARAM
HTML element may not have content and it has no end-tag.
The choices I'm considering, are:
- html-encode the xml structure and send it to applet in a single PARAM object
- creating a list of PARAM objects and constructing their names like "File1", "Description1", "File2", "Description2", "File3"... then in Java applet create a while loop to read filenames while there is any.
However, none of the solutions seems to be elegant. The question is, what's the best practice in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以逗号分隔传递它们:
然后使用
String.split()
:如果结构更复杂,您可以使用 JSON 来表示它们。
Pass them comma-separated:
and then use
String.split()
:In case of more complex structures you can use JSON to represent them.
您还可以为您的小程序提供一个公共方法:
并从 javascript 代码调用此方法(您可以在其中循环)
You can also provide your applet with a public method:
and call this method from javascript code (in which you can loop)