最简单的方法就是:把它们放在同一个目录就不用设置啦。。。,但是,不方便管理,这是最次的做法啊,不可取了。
把jsp和applet放在同一目录是可以解决此问题,但是不利于文件的分类管理
而且分开放的话,codebase="../web-inf/class/abc/"也是不对的
因为codebase是URL
This OPTIONAL attribute specifies the base URL of the applet--the directory that contains the applet's code. If this attribute is not specified, then the document's URL is used.
我现在已经找到原因,
applet的class文件不能放在web-inf目录下,
因为这是个特殊目录,所以http://localhost:8080/test/servlet/不能找到applet1.class这个文件。
正确的方法是在/webapps/test/下新建1个文件夹,将applet的class文件放在里面,在重新设置codebase属性
例如:
目录结构
测试用的jsp /webapps/test/jsp/test.jsp
jsp中插入的applet的class /webapps/test/applet/abc/Applet1.class
URL
http://localhost:8080/test/jsp/test.jsp
test.jsp中的部分代码
<jsp:plugin type="applet" code="abc.Applet1.class"
width="475" height="350" codebase="/test/applet/">
<jsp:params>
<jsp:param name="MESSAGE" value="Your Message Here" />
</jsp:params>
</jsp:plugin>