我正在尝试在此页面上部署“texteditor-applet”示例:Glassfish上的http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/usingJNLPAPI.html。
我创建了TextApplet.war,它部署得很好,但是当我在localhost上访问时出现了这个错误:
FialedDownload异常无法加载资源:
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有问题,我不知道只是猜测。
答案 0 :(得分:2)
我得到了解决这个问题的方法。看起来从此linke下载的软件包中缺少“applet_JNLP_API.jar”:http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/examplesIndex.html#AppletJNLPAPI
我在这里找到了它:
将它添加到我的项目并且工作正常,谢谢。