我做了一个JavaBean程序但是调用的时候老是出错不知道为什么!!郁闷!请高手解答。
这个是程序出错信息:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 2 in the jsp file: /FileBox.jspGenerated servlet error:
[javac] Compiling 1 source fileC:\Tomcat 5.0\work\Catalina\localhost\jsp\org\apache\jsp\FileBox_jsp.java:42: cannot access test.BoxAn error occurred at line: 2 in the jsp file: /FileBox.jspGenerated servlet error:
bad class file: G:\jsp\WEB-INF\classes\test\Box.class
class file contains wrong class: Box.Box
Please remove or make sure it appears in the correct subdirectory of the classpath.
test.Box box = null;
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
这个是程序出错信息:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 2 in the jsp file: /FileBox.jspGenerated servlet error:
[javac] Compiling 1 source fileC:\Tomcat 5.0\work\Catalina\localhost\jsp\org\apache\jsp\FileBox_jsp.java:42: cannot access test.BoxAn error occurred at line: 2 in the jsp file: /FileBox.jspGenerated servlet error:
bad class file: G:\jsp\WEB-INF\classes\test\Box.class
class file contains wrong class: Box.Box
Please remove or make sure it appears in the correct subdirectory of the classpath.
test.Box box = null;
^
1 error
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
package test;
public class Box
{
double length;
double width;
double height;
public Box()
{
length=0;
width=0;
height=0;
}
public void setLength(double length)
{
this.length=length;
}
public double getLength()
{
return length;
}
public void setWidet(double width)
{
this.width=width;
}
public double getWidet()
{
return width;
}
public void setheight(double height)
{
this.height=height;
}
public double volumn()
{
double volumnValue;
volumnValue=length*width*height;
return volumnValue;
}
public double surfaceArea()
{
double surfaceAreaValue;
surfaceAreaValue=length*width*2+width*height*2+height*length*2;
return surfaceAreaValue;
}
}
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<jsp:useBean id="box" scope="page" class="test.Box" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Box</title>
</head>
<body><%
box.setLength(10);
box.setWidth(11);
box.setHeight(12);
out.println("在JSP中使用JavaBean<br>");
out.println("盒子的长度为:"+box.getLength()+"<br>");
out.println("盒子的宽度为:"+box.getWidth()+"<br>");
out.println("盒子的高度为:"+box.getHeight()+"<br>");
out.println("盒子的容积为:"+box.volumn()+"<br>");
out.println("盒子的表面积为:"+box.surfaceArea()+"<br>");
%>
</body>
</html>我将class类放到了WEB-INF\classes\test目录下为什么还出错!
怎么会有这个类呢
怎么里面的方法有好几处错误,我试了,jsp页面上要import test.Box
而且文件要放对地方,执行没有问题