在JSP中添加applet出错
用Myeclipse新建的工程
JSP代码
<%@ page contentType="text/html; charset=utf-8" language="java" %>
<center>
使用JSP在页面中添加Applet<hr><br>
<jsp:plugin codebase="../src/bin/" code="com.mytest.MyApplet.class" type="applet"
align="middle" width="600" height="300">
<jsp:params><jsp:param name="image" value="image/desert.jpg"/></jsp:params>
<jsp:fallback>在插入时产生了错误</jsp:fallback>
</jsp:plugin>
</center>
java代码
package com.mytest;import java.awt.*;import javax.swing.*;public class MyApplet extends JApplet{ String img; public void paint(Graphics g){ Image image = this.getImage(this.getCodeBase(),img); g.drawImage(image, 0, 0, 600,300,this); g.setColor(Color.red); g.setFont(new Font("楷体",10,24)); g.drawString("使用JSP:plugin在JSP页面中添加Applet", 60, 280); g.setFont(new Font("宋体",10,36)); g.setColor(Color.pink); g.drawString(new java.util.Date().toString(), 30, 30); } public void init(){ img = this.getParameter("image"); }}