我在从 tomcat 6 servlet 提供的 HTML 页面中有一个小程序。小程序元素如下:
<applet code="com.iteloffice.cuba4remedy.cubaapplet.class" name="cubaapplet"
codebase="http://localhost:8080/cuba4remedy/classes" width="400" height="400" MAYSCRIPT>
<param name="populatefunction" value="populatedropdown">
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</applet>
在我的开发机器上,小程序下载得很好。但是在具有完全相同版本的 Java 和 tomcat 的目标机器上,我得到了如下 IE9 中所示的小程序错误。
Java Plug-in 1.6.0_26
Using JRE version 1.6.0_26-b03 Java HotSpot(TM) Client VM
User home directory = C:\Users\Administrator
load: class com.iteloffice.cuba4remedy.cubaapplet.class not found.
java.lang.ClassNotFoundException: com.iteloffice.cuba4remedy.cubaapplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.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)
Exception: java.lang.ClassNotFoundException: com.iteloffice.cuba4remedy.cubaapplet.class
如何验证类路径的路径?
EG tomcat 已开启http://192.168.0.6:8080
webapps
文件夹是cuba4remedy
我应该能够在我的网络浏览器中输入此路径吗?
http://192.168.0.6:8080/cubaremedy/com/iteloffice/cuba4remedy/cubaapplet.class
小程序中的 package 语句为:
package com.iteloffice.cuba4remedy;
在tomcat文件夹结构是这样的:
tomcat_root/webapps/cuba4remedy
里面cuba4remedy
的类文件在:
WEB-INF/classes/com/iteloffice/cuba4remedy
编辑:
为了解决这个问题,我如下更改了小程序标记并将小程序类文件放在 webapps 根文件夹中
<applet code="cubaapplet.class" name="cubaapplet"
codebase="/cuba4remedy" width="400" height="400" MAYSCRIPT>
<param name="populatefunction" value="populatedropdown">
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</applet>
我看到另一篇关于无法访问 servlet 可以访问的相同路径的帖子如此简化。
将代码库更改为 / 使其更加灵活。