目录: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> </td>
<td> </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.
拿书上的源码直接运行,却可以,就是我写的不可以,真邪门啊。
请大家帮忙下啦。歇歇了。
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> </td>
<td> </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.
拿书上的源码直接运行,却可以,就是我写的不可以,真邪门啊。
请大家帮忙下啦。歇歇了。
說找不到你那個people里面的值
但我不懂你這句詩什么意思
public People(){
}
構造器里面的值?
可那里面沒值呀
在jsp中该为:<jsp:useBean id="test" scope="page" class="com.po.People" />
我试了下,加包还是这个错误:The value for the useBean class attribute com.po.People is invalid.这到底是怎么回事呀。
是說你的這個People不可用,沒有值或其他什么的
你加了包的話表明的調的是People這個class了
<jsp:useBean id="test" scope="page" class="People" />
<jsp:setProperty name="test" property="*" />
你這兩句話調的是People這個class?
直接調用bean?
不懂你的這個寫法
順便問下 你jasper這個jar導了吧
改成 get 試試
<jsp:setProperty name="test" property="*" />
这句话是设置属性哇。
1
引用自定义的一个id为text 的实体类People(class="People" 这肯定有问题)
那你设置这个name为"text"的属性干吗?2
import“java.sql.*” 干吗?没用上把?最好不要在jsp页面上访问数据库
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类的路径
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.sql.*" errorPage="" iserrorPage="false"%>