目录:D:\Tomcat6.0\webapps\test\test.html;
     D:\Tomcat6.0\webapps\test\test.jsp;
     D:\Tomcat6.0\webapps\test\WEB-INF\web.xml;
     D:\Tomcat6.0\webapps\test\WEB-INF\src\People.java;
     D:\Tomcat6.0\webapps\test\WEB-INF\classes\People.class;
文件内容:
test.html:<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<form id="form1" name="form1" method="post" action="test.jsp">
  <table width="404" border="1">
    <tr>
      <td width="105">名字:</td>
      <td width="283"><label>
        <input name="name" type="text" id="name" />
      </label></td>
    </tr>
    <tr>
      <td>密码:</td>
      <td><label>
        <input name="password" type="text" id="password" />
      </label></td>
    </tr>
    <tr>
      <td>操作:</td>
      <td><label>
        <input type="submit" name="Submit" value="提交" />
      </label>
        <label>
        <input type="reset" name="Submit2" value="重置" />
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>test.jsp:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %><html xmlns="http://www.w3.org/1999/xhtml">
<jsp:useBean id="test" scope="page" class="People" />
<jsp:setProperty name="test" property="*" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table width="325" border="1">
  <tr>
    <td width="60">名字:</td>
    <td width="249"><jsp:getProperty name="test" property="name" /></td>
  </tr>
  <tr>
    <td>密码:</td>
    <td><jsp:getProperty name="test" property="password" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>People.java:public class People
{
private String name;
private String password;

public People(){
}

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

public String getName(){
return this.name;
}
public String getPassword(){
return this.password;
}
}访问test.html,提交后,就出现如下错误:type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /test.jsp(4,0) The value for the useBean class attribute People 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:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Generator.generate(Generator.java:3372)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
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.16 logs.谁能解释下为什么?我调试了n天了,无论怎么写,都是这个错误:The value for the useBean class attribute People is invalid.
拿书上的源码直接运行,却可以,就是我写的不可以,真邪门啊。
请大家帮忙下啦。歇歇了。

解决方案 »

  1.   

    <jsp:useBean id="test" scope="page" class="People" />
    說找不到你那個people里面的值
    但我不懂你這句詩什么意思
      

  2.   

    是取那個
    public People(){
    }
    構造器里面的值?
    可那里面沒值呀
      

  3.   

    JavaBean里不是必须要有一个空构造吗
      

  4.   

    你的代码在我本地运行会出现找不到People类的异常解决办法:给people类增加包, package com.po;
    在jsp中该为:<jsp:useBean id="test" scope="page" class="com.po.People" />
      

  5.   

    我没有使用包呀。
    我试了下,加包还是这个错误:The value for the useBean class attribute com.po.People is invalid.这到底是怎么回事呀。
      

  6.   

    不是包的問題吧
    是說你的這個People不可用,沒有值或其他什么的
    你加了包的話表明的調的是People這個class了
    <jsp:useBean id="test" scope="page" class="People" />
    <jsp:setProperty name="test" property="*" />
    你這兩句話調的是People這個class?
    直接調用bean?
    不懂你的這個寫法
    順便問下  你jasper這個jar導了吧
      

  7.   

    没用包那你那个person类放在那?包名不写全找不到
      

  8.   

    <jsp:setProperty name="test" property="*" />
    改成  get 試試
      

  9.   


    <jsp:setProperty name="test" property="*" />
    这句话是设置属性哇。
      

  10.   


    1
    引用自定义的一个id为text 的实体类People(class="People" 这肯定有问题)
    那你设置这个name为"text"的属性干吗?2
    import“java.sql.*” 干吗?没用上把?最好不要在jsp页面上访问数据库
      

  11.   

    嘿嘿,不如看看我们的jsp教程哦,里边都有直接可以运行的例子。省得自己调试出问题咯http://www.family168.com/tutorial/jsp/html/
      

  12.   

    偶解决了,有个地方你没加
    test.jsp中这个地方
    <%@ page contentType="text/html;charset=gb2312"%>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <jsp:useBean id="test" scope="page" class="tom.jiafei.People" />
    <jsp:setProperty name="test" property="*" />
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    你没加bean类的路径
      

  13.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>你试着讲上面一句分开写我也翻过这样的错误你试试吧也许行得通
    <%@ page contentType="text/html; charset=gb2312" language="java"%>
    <%@ page import="java.sql.*" errorPage="" iserrorPage="false"%>