日期:2014-05-18  浏览次数:20711 次

请问:我的javabean是哪里不对?
我用的eclipse3.2   +   tomcat6.0,之前单纯做jsp时是对的,所以设置肯定没有问题
index.jsp(存放在D:\MyWebSite\testJavaBean\)代码如下:

<%@   page   contentType= "text/html;   charset=gb2312 "   %>
<%@page   import= "myJavaBean.Person "%>
<jsp:useBean   id= "person "   class= "Person "   scope= "page "> </jsp:useBean>
<jsp:setProperty   name= "person "   property= "name "   value= "biwei "/>
<html>
<head> </head>
<body>
<%   out.print(person.getName());   %>
</body>
</html>

Person.java(存放在D:\MyWebSite\testJavaBean\WEB-INF\src\myJavaBean\)代码如下:

package   myJavaBean;

public   class   Person  
{
String   name;

public   String   getName()   {
return   name;
}

public   void   setName(String   name)   {
this.name   =   name;
}

}
编译生成的Person.class在D:\MyWebSite\testJavaBean\WEB-INF\classes\myJavaBean
在ie中输入http://localhost:8080/testJavaBean/index.jsp后,错误如下:

HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   /index.jsp(3,0)   The   value   for   the   useBean   class   attribute   Person   is   invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/6.0.10   logs.


----------------------------------------