The value for the useBean class attribute com.Student is invalid.
Student.java的代码
package com;
import java.io.*;
public class Student {
String name = null;
long number;
double height,weight;
public String getName() {
try{
byte b[]=name.getBytes("ISO-8859-1");
name = new String(b);
}catch(Exception e){
return name;
}
return name;
}
public void setName(String name) {
this.name = name;
}
public long getNumber() {
return number;
}
public void setNumber(long number) {
this.number = number;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
}
Student.jsp的代码
<%@ page language="java" contentType="text/html; charset=gb2312"
%>
<%@page import="com.Student"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="" method="post">
<p>输入学生的姓名
<input type="text" name="name">
<p>输入学生的学号:
<input type="text" name="number">
<p>输入学生的身高:
<input type="text" name="height">
<p>输入学生的体重:
<input type="text" name="weight">
<p></p>
<input type="submit" value="登陆">
</form>
<jsp:useBean id="lizhe" class="com.Student" scope="page"></jsp:useBean>
<jsp:setProperty name="lizhe" property="*"/>
<p>姓名:
<jsp:getProperty name="lizhe" property="name"/>
<p>学号:
<jsp:getProperty name="lizhe" property="number"/>
<p>身高:
<jsp:getProperty name="lizhe" property="height"/>
<p>体重:
<jsp:getProperty name="lizhe" property="weight"/>
</body>
</html>
错误的信息
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /Student.jsp(24,0) The value for the useBean class attribute com.Student is invalid.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: /Student.jsp(24,0) The value for the useBean class attribute com.Student is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1174)
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:3304)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.
--------------------------------------------
[解决办法]
直接用Student好了
[解决办法]
http://hi.baidu.com/xcwll/blog/item/f7fa66f00f5958c97831aa55.html
[解决办法]
在JSP页面用import com.*试一下
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html