我正在尝试使用新的 Java JNLP 规范部署 Applet,但我总是收到 Java 插件控制台的以下错误:
BadFieldException[ Il campo <jnlp><applet-desc>width presenta un valore non valido: 0,0]
这是我的 HTML 代码:
<script>
var attributes = { id:'signingApplet', code:'it.insielmercato.web.signing.SigningApplet' ,width:0, height:0 } ;
var parameters = {jnlp_href: 'signing-applet.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6');
function setClipboardText(text){
signingApplet.setClipboardContent(text);
}
</script>
这是我的 JNLP 代码:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.5+" codebase="" href="">
<information>
<title>SigningApplet</title>
<vendor>Insielmercato S.P.A.</vendor>
</information>
<resources>
<!-- Application Resources -->
<j2se version="1.6+"
href="http://java.sun.com/products/autodl/j2se"/>
<jar href="signing-1.0.jar" main="true" />
</resources>
<applet-desc name="Signing Applet" main-class="it.insielmercato.web.signing.SigningApplet" width="0" height="0">
</applet-desc>
<update check="background"/>
</jnlp>
还有我的小程序代码:
package it.insielmercato.web.signing;
import java.applet.Applet;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
public class SigningApplet extends Applet implements ClipboardOwner {
/**
*
*/
private static final long serialVersionUID = 5272223219287676996L;
private void loadAppletParameters(){
}
public void init(){
loadAppletParameters();
}
public void setClipboardContent(String text){
StringSelection ss = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(ss, this);
}
public void lostOwnership(Clipboard clipboard, Transferable contents) {
}
public String getClipBoardContent(){
String content = null;
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard.getContents(null);
boolean hasTransferableText = (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
if(hasTransferableText)
try {
content = (String)contents.getTransferData(DataFlavor.stringFlavor);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
}
我哪里错了?