gpt4 book ai didi

java - "Accessing the Client Using JNLP API"示例,部署在 GlassFish 上时出现错误 : FailedDownload Exception,

转载 作者:行者123 更新时间:2023-11-30 04:38:06 25 4
gpt4 key购买 nike

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

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

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 有问题,我不知道只是猜测。

最佳答案

我找到了这个问题的解决方案。看起来从此链接下载的包中缺少“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

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

关于java - "Accessing the Client Using JNLP API"示例,部署在 GlassFish 上时出现错误 : FailedDownload Exception,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12939568/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com