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

求救贴:碰到过的帮帮忙了javabean出现unable to compile class for jsp (在线等)
试验一个小小的javabean程序   可是老是出现错误   代码如下:
TestBean.java:
package   test;

public   class   TestBean   {
String   name;
public   TestBean(){}
public   void   setName(String   name)
{
this.name=name;
}
public   String   getName()
{
return   this.name;
}
}
index.jsp
<%@   page   language= "java "   import= "test.TestBean "   %>
<html>    
    <head>    
        <title> My   JSP   'index.jsp '   starting   page </title>
    </head>
    <body>  
<jsp:useBean   id= "testBeanEx "   scope= "page "   class= "TestBean "/>
    </body>
</html>
运行信息:
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:   /WebRoot/index.jsp(7,1)   The   value   for   the   useBean   class   attribute   TestBean   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.


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

Apache   Tomcat/6.0.10

tomcat6.0   下localhost:8080运行正常   其中实例运行正常   HelloWorld.java运行正常
配置了好久   就是不知道问题在哪里   高手指点下吧

------解决方案--------------------<