0

我刚刚开始学习jsp,我遇到了从jsp运行Applet,下面的代码似乎不起作用。

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>InfoVisual</title>
    </head>
    <body>
    <jsp:plugin type="applet"  codebase="WEB-INF/classes" code="DemoApplet.class"  width="400" height="400">
      <jsp:fallback>
       <p>Unable to load applet</p>
       </jsp:fallback>
    </jsp:plugin>
        <input name="btnShow" value="Show" type="submit">
    </body>
</html>

我的eclipse项目结构如下

在此处输入图像描述

我不知道为什么我看不到小程序运行。我是否将文件放在正确的文件夹中???

4

2 回答 2

2

Classes in WEB-INF/classes are only visible to server-side code such as servlets. Instead create a JAR file containing the compiled classes required to run the applet are place them in the same location as the JSP file. The plugin tag will then look like

<jsp:plugin type="applet"  code="DemoApplet.class" archive="MyAppletJar.jar" width="400" height="400">
  <jsp:fallback>
   <p>Unable to load applet</p>
   </jsp:fallback>
</jsp:plugin>
于 2013-10-14T15:16:10.383 回答
0

这段代码运行良好:

<applet code="DemoApplet.class" name="DemoApplet" archive="DemoApplet.jar" width=300 height=300>
</applet>

这是我的项目结构:

在此处输入图像描述

感谢您的帮助:))

于 2013-10-14T16:12:07.503 回答