今天同事碰到一个问题,HTML页面里面加入Applet不能正确初始化.从网上下载的Demo文档可以正常运行,但是放到Tomcat下面就不行了.因为我以前也没有做过Applet,所以就拿过问题看了一下.
Demo目录结构是这样的:
demo
|-demo.html
|-lib
|-*.jar
Applet的定义如下:
<APPLET CODE = "javazoom.upload.client.MApplet.class" JAVA_CODEBASE = "./" ARCHIVE = "lib/jclientupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH = "250" HEIGHT = "250" NAME = "clientupload"></XMP>
<PARAM NAME = CODE VALUE = "javazoom.upload.client.MApplet.class" >
<PARAM NAME = CODEBASE VALUE = "./" >
<PARAM NAME = ARCHIVE VALUE = "lib/jclientupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" >
<PARAM NAME = NAME VALUE = "clientupload" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME = "url" VALUE="http://localhost:8080/uploadbean/process.jsp">
<PARAM NAME = "paramfile" VALUE="uploadfile">
<PARAM NAME = "param1" VALUE="todo">
<PARAM NAME = "value1" VALUE="upload">
<PARAM NAME = "mode" VALUE="http">
</APPLET>
拿过这个东西,我顺手就把lib目录放到了WEB-INF目录下,然后更改ARCHIVE的VALUE,结果还是不行.晕~~~
稍后想明白了,我做了一件愚蠢的事情,WEB-INF目录下的文件是客户端所访问不到的!新建一个applet目录,然后拷贝文件,改路径,搞定.
Make things as simple as possible, but no simpler.