主题:一个检验bean的小程序,出错了,大家帮忙看看,定加分
test.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="com.bean.NameBean"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'test.jsp' starting page</title>
</head>
<body>
<jsp:useBean id="nbean" class="com.bean.NameBean" scope="session"/>
<jsp:setProperty name="nbean" Property="name"/>
<jsp:setProperty name="nbean" Property="id"/>
name : <jsp:getProperty name="nbean" Property="name"/>
id : <jsp:getProperty name="nbean" Property="id"/>
</body>
</html>
--------------------------------------
package com.bean;
public class NameBean {
private String name;
private String id;
public NameBean(String name,String id)
{
this.name=name;
this.id=id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
----------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>hello.html</title>
</head>
<form action="test.jsp"method="post">
<table>
name <input type="text"name="name">
id<input type="text"name="id">
<input type="submit" value="提交"/>
</table>
</form>
<body>
</body>
</html>
The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /test.jsp(13,3) SetProperty: Mandatory attribute property missing
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:198)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:284)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:475)
org.apache.jasper.compiler.Node$SetProperty.accept(Node.java:1086)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2166)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2216)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2222)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2166)
org.apache.jasper.compiler.Validator.validate(Validator.java:1484)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java
<%@ page language="java" pageEncoding="utf-8"%>
<%@ page import="com.bean.NameBean"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'test.jsp' starting page</title>
</head>
<body>
<jsp:useBean id="nbean" class="com.bean.NameBean" scope="session"/>
<jsp:setProperty name="nbean" Property="name"/>
<jsp:setProperty name="nbean" Property="id"/>
name : <jsp:getProperty name="nbean" Property="name"/>
id : <jsp:getProperty name="nbean" Property="id"/>
</body>
</html>
--------------------------------------
package com.bean;
public class NameBean {
private String name;
private String id;
public NameBean(String name,String id)
{
this.name=name;
this.id=id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
----------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>hello.html</title>
</head>
<form action="test.jsp"method="post">
<table>
name <input type="text"name="name">
id<input type="text"name="id">
<input type="submit" value="提交"/>
</table>
</form>
<body>
</body>
</html>
The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /test.jsp(13,3) SetProperty: Mandatory attribute property missing
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:198)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:284)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:475)
org.apache.jasper.compiler.Node$SetProperty.accept(Node.java:1086)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2166)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2216)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2222)
org.apache.jasper.compiler.Node$Root.accept(Node.java:457)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2166)
org.apache.jasper.compiler.Validator.validate(Validator.java:1484)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java