81,092
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<jsp:useBean id="student" class="szenjinn.Studen" scope="application"/>
<jsp:setProperty name="student" property="*"/>
<!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=GBK">
<title>UseBean Example</title>
</head>
<body>
<form action="showBeanContext.jsp" method="get">
<br>学生号:<input type="text" name="id">
<br> 姓名:<input type="text" name="name">
<br> 年龄:<input type="text" name="age">
<br> 出生日期:<input type="text" name="birthday">
<input type="submit" value="提交">
<input type="reset" value="清空">
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=GBK"
pageEncoding="GBK"%>
<!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=GBK">
<title>useBean Example</title>
</head>
<body>
<br>学生号:<jsp:getProperty property="student" name="id"/>
<br> 姓名:<jsp:getProperty property="student" name="name"/>
<br> 出生日期:<jsp:getProperty property="student" name="birthday"/>
</body>
</html>
package szenjinn;
public class Studen {
private String id = null;
private String name = null;
private int age;
private String birthday = null;
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void SetAge(int age) {
this.age = age;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getBirthday() {
return birthday;
}
}
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: jsp:getProperty for bean with name 'id'. Name was not previously introduced as per JSP.5.3
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1086)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1124)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Generator.generate(Generator.java:3416)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.