我的工程部署在tomcat下,假设我的工程名为“tttt”,在tttt中有两个文件夹:com和pages。其中com里面有b.class,pages里面有a.jsp。 
那么我在本机上的完整目录就应该是: 
e:\tomcat6\webapps\tttt\WEB-INF\com\b.class 
e:\tomcat6\webapps\tttt\pages\a.jsp 
我想在a.jsp中调用b.class这个applet文件,其中的HTML代码是这么写的: 
<applet code="com.b.class" width="150" height="80"></applet> <applet code="WEB-INF.com.b.class" width="150" height="80"></applet> 
和 
<applet code="com.b.class" width="150" height="80"></applet> 
可是控制台报错: 
java.lang.ClassNotFoundException: com.b.class 
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8090/tttt/pages/com/b/class.class 
和 
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8090/tttt/pages/WEB-INF/com/b/class.class 如果我这么写: 
<applet code="b.class" codebase="/tttt/com/" width="150" height="80"></applet> 
会出现这个错误: 
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8090/tttt/com/b/class.class 后面用“.”也不行: 
<applet code="b.class" codebase="/tttt/com/b.class" width="150" height="80"></applet> 
出现: 
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8090/tttt/com/b.class/b/class.class 我很困惑:为什么每个错误后面都有一个b/class.class?我并没有这个.class文件! 
那么如何写HTML代码才能够使其访问到b.class这个applet文件呢?

解决方案 »

  1.   

    applet的中的类不要用.class的文件后缀名。
    直接用com.b就可以。另外
    <applet code="com.b" width="150" height="80"> </applet> 
    这样写的话,你b.class文件就应该放到tttt/pages/com/目录下
      

  2.   


    <applet code="com.b" width="150" height="80"> </applet> 谢谢您的回答,如果把b.class放在pages\com下,可以访问了。
    但是如果我要访问在e:\tomcat6\webapps\tttt\WEB-INF\com\b.class的这个applet该如何写呢?<applet code="b" codebase="/tttt/com/" width="150" height="80"> </applet> 
    可是出现:
    java.lang.ClassNotFoundException: b
    Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8090/tttt/com/b.class