- 论坛徽章:
- 0
|
环境:Apache Tomcat 5.5.20
//下面是一个javabean
package dbjs;
import java.io.*;
public class Circle
{
int radius;
public Circle()
{
radius=1;
}
public int getRadius()
{
return radius;
}
public void setRadius(int newRadius)
{
radius=newRadius;
}
public double circleArea()
{
return Math.PI*radius*radius;
}
public double circleLength()
{
return 2.0*Math.PI*radius;
}
}
通过javac Circle.java 生成.class文件存放与当前目录下.
把当前目录设置在环境变量CLASSPATH 中
//下面是 jsp页面:
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.* "%>
<%@ page import= "Circle" %>
<HTML>
<BODY>
<jsp:useBean id="girl" class="dbjs.Circle" scope="page" >
</jsp:useBean>
<% girl.setRadius(100); %>
<P>圆的半径是:<%=girl.getRadius()%>
<P>圆的周长是:<%=girl.circleArea()%>
<P>圆的面积是:
</BODY>
</HTML>
报错信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /example5_1.jsp(6,2) The value for the useBean class attribute dbjs.Circle is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
这是我抄书上的一个例子,什么原因呢/ |
|