1

我正在尝试在此页面上部署“texteditor-applet”示例: Glassfish 上的http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/usingJNLPAPI.html

我制作了 TextApplet.war,它部署得很好,但是在我的本地主机上访问时,我收到了这个错误:

FialedDownload 异常无法加载资源:

http://localhost:8080/TextApplet/applet_JNLP_API.jar

GlassFish 运行良好,这是 TextApplet.war 结构:

-index.html
-texteditor-applet(JNLP): archive
-WEB-INF:
|--web.xml

索引.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-US">
  <head>
    <title>Text Editor Applet Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  </head>
  <body>
    <noscript> 
    A browser with JavaScript enabled is required for this page to operate properly.
    </noscript>

    <h1>Text Editor Applet Demo</h1>
    <p>Click the Open button and open a plain text file.</p>
    <p>Edit the text and click the Save button</p>
    <script src="http://www.java.com/js/deployJava.js"></script>
    <script> 
        var attributes = { code:'TextEditorApplet.class', archive:'applet_JNLP_API.jar',  width:500, height:300} ;
        var parameters = {jnlp_href: 'texteditor-applet.jnlp'} ;
        deployJava.runApplet(attributes, parameters, '1.6');
    </script>
  </body>
</html>

我什至试过这个:注意区别:

var parameters = {jnlp_href: 'http://localhost:8080/TextApplet/texteditor-applet.jnlp'} ;

索引.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en-US">
  <head>
    <title>Text Editor Applet Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  </head>
  <body>
    <noscript> 
    A browser with JavaScript enabled is required for this page to operate properly.
    </noscript>

    <h1>Text Editor Applet Demo</h1>
    <p>Click the Open button and open a plain text file.</p>
    <p>Edit the text and click the Save button</p>
    <script src="http://www.java.com/js/deployJava.js"></script>
    <script> 
        var attributes = { code:'TextEditorApplet.class', archive:'applet_JNLP_API.jar',  width:500, height:300} ;
        var parameters = {jnlp_href: 'http://localhost:8080/TextApplet/texteditor-applet.jnlp'} ;
        deployJava.runApplet(attributes, parameters, '1.6');
    </script>
  </body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
</web-app>

有人能告诉我为什么我会收到这个错误吗?也许 web.xml 有问题,我不知道只是猜测。

4

1 回答 1

2

我得到了这个问题的解决方案。看起来从这个链接下载的包中缺少“applet_JNLP_API.jar”:http: //docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/examplesIndex.html#AppletJNLPAPI

我在这里找到了它:

http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/examples/dist/applet_JNLP_API/AppletPage.html

将其添加到我的项目中并且工作正常,谢谢。

于 2012-10-17T20:36:13.057 回答