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

问初级的JAVABEAN问题
小弟在运行这个文件时.出现错误页面:
type   Exception   report

message  

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

exception  

org.apache.jasper.JasperException:   /02_23.jsp(12,0)   The   value   for   the   useBean   class   attribute   BeanExample.SimpleBean   is   invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


原02_23.JSP文件如下
<html>  
<head>  
<title> 一个useBean动作的例子 </title>  
</head>  
<%@   page   contentType= "text/html;charset=GB2312 "   %>
<body>  
<center>
<h2>
这是一个使用useBean动作的例子
</h2>  
</center>
<jsp:useBean   id= "test "   class= "BeanExample.SimpleBean "   scope= "page "/>
<%   test.setString( "This   is   a   useBean   Action   example ");   %>
<p>  
<h3>
<%=test.displayString()%>
</h3>
</p>
</body>
</html>  
原SimpleBean.java文件如下:

package   BeanExample;

public   class   SimpleBean
{
        String   str= " ";
       
        public   SimpleBean()
        {
              str= "This   is   the   inital   string ";
        }  
       
        public   void   setString(String   str1)
        {
        str= "Hello!   "+str1;
        }