Struts web项目中Applet加载错误
当我尝试在 Struts Web 项目中的 JSP 文件中使用标记来加载小程序时,我遇到了与“ClassNotFoundException”相关的令人沮丧的错误:
load: class com.superdeporter.audio.AudioApplet.class not found.
java.lang.ClassNotFoundException: com.superdeporter.audio.AudioApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/SampleAudioApplication/com/superdeporter/audio/AudioApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
这是 JSP 文件中的小程序代码:
<jsp:plugin type="applet" name="AudioApplet"
code="AudioApplet.class" codebase="/com/superdeporter/audio" width="100"
height="100" align="middle" jreversion="1.5"
archive="">
</jsp:plugin>
这似乎是一个奇怪的问题。顺便说一句,我已经尝试了许多代码和代码库参数的组合,但仍然遇到相同的错误。据我所知,code参数应该以Applet类的名称作为值,codebase参数应该以该applet类的包路径作为值。我错了吗?
遇到这个问题的人可以与我分享他/她的意见吗?这个问题有解决办法吗?也欢迎任何有关如何在 Struts Web 项目中使用小程序的建议。
I'm getting frustrating errors related with "ClassNotFoundException" when I try to load an applet by using tag inside a JSP file within a Struts web project:
load: class com.superdeporter.audio.AudioApplet.class not found.
java.lang.ClassNotFoundException: com.superdeporter.audio.AudioApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/SampleAudioApplication/com/superdeporter/audio/AudioApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
And this is the applet code within a JSP file:
<jsp:plugin type="applet" name="AudioApplet"
code="AudioApplet.class" codebase="/com/superdeporter/audio" width="100"
height="100" align="middle" jreversion="1.5"
archive="">
</jsp:plugin>
This seems to be a strange problem. By the way, let me say I have tried many combinations of code and codebase parameters and I was still getting the same errors. As I know, code parameter should have the name of Applet class as value and codebase parameter should have that applet class' package path as the value. Am I wrong?
Can anyone who faced this problem share his/her opinions with me? Is there a solution to this problem? Any suggestions on how to use applets within a Struts web project are also welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
codebase 参数实际上是服务器上 applet 类文件相对于调用 applet 的 jsp 页面的位置。 applet 类需要位于可公开访问的目录中,因此标准的 /WEB-INF/classes 目录将不起作用。
实现某些功能的最快路径是完全省略 codebase 参数,并将 AudioApplet.class 放在与 jsp 相同的目录中。请参阅下面的示例:
The codebase parameter is actually the location of the applet class file on the server relative to the jsp page that is calling the applet. The applet class needs to be in a directory that is publicly accessible, so the standard /WEB-INF/classes directory won't work.
The fastest path to get something working would be to omit the codebase parameter completely and just put AudioApplet.class in the same directory as the jsp. See below for an example: