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)