首页上一页 1 下一页尾页 1 条记录 1/1页
java web入门到精通的学习问题
发表在JavaWeb图书答疑
2015-11-24
是否精华
是
否
版块置顶:
是
否
java web入门到精通 第七章 7.2.1获取JavaBean 属性信息
produce.java代码:
public class Produce{
//商品名称
private String name="电吉他";
//商品价格
private double price=1880.5;
//数量
private int count=100;
//出厂地址
private String factoryAdd="吉林省长春市XXX琴行";
public String getName(){
return name;
}
public double getPrice(){
return price;
}
public int getCount(){
return count;
}
public String getFactoryAdd(){
return factoryAdd;
}
}
7-2.jsp代码:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<jsp:useBean id="procuce" class="com.lyq.bean.entity.procuce"></jsp:useBean>
<div>
<ul>
<li>商品名称:<jsp:getProperty property="name" name="produce" /></li>
<li>价格:<jsp:getProperty property="price" name="produce" /></li>
<li>数量:<jsp:getProperty property="count" name="produce" /></li>
<li>厂址:<jsp:getProperty property="factoryAdd" name="produce" /></li>
</ul>
</div>
</body>
</html>
javabean存储位置:E:\JspStudy\WWW\com\lyq\bean\entity\produce
错误提示:
HTTP Status 500 - /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce is invalid.
type Exception report
message /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce is invalid.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce 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:1238)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
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:3474)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
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:723)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.39 logs.
produce.java代码:
public class Produce{
//商品名称
private String name="电吉他";
//商品价格
private double price=1880.5;
//数量
private int count=100;
//出厂地址
private String factoryAdd="吉林省长春市XXX琴行";
public String getName(){
return name;
}
public double getPrice(){
return price;
}
public int getCount(){
return count;
}
public String getFactoryAdd(){
return factoryAdd;
}
}
7-2.jsp代码:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<jsp:useBean id="procuce" class="com.lyq.bean.entity.procuce"></jsp:useBean>
<div>
<ul>
<li>商品名称:<jsp:getProperty property="name" name="produce" /></li>
<li>价格:<jsp:getProperty property="price" name="produce" /></li>
<li>数量:<jsp:getProperty property="count" name="produce" /></li>
<li>厂址:<jsp:getProperty property="factoryAdd" name="produce" /></li>
</ul>
</div>
</body>
</html>
javabean存储位置:E:\JspStudy\WWW\com\lyq\bean\entity\produce
错误提示:
HTTP Status 500 - /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce is invalid.
type Exception report
message /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce is invalid.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /7-2.jsp(10,0) The value for the useBean class attribute com.lyq.bean.entity.procuce 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:1238)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1178)
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:3474)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:231)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
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:723)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.39 logs.