1

Glassfish のhttp://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/usingJNLPAPI.htmlの「texteditor-applet」の例をデプロイしようとしています。

私は TextApplet.war を作成しました。正常にデプロイされますが、localhost でアクセスすると、次のエラーが発生します。

FialedDownload Exception リソースをロードできません:

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

GlassFish は正常に動作しています。これは TextApplet.war 構造です。

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

index.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'} ;

index.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 に答える