Book.java
package bean;
public class Book {
// 编号
private int id=7;
// 图书名称
private String name="JSP程序设计与案例实战";
// 价格
private double price=50;
// 数量
private int count=50;
// 作者
private String author="浪潮优派";
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
}
get.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>获取JavaBean的属性信息</title>
</head>
<body>
<jsp:useBean id="book" class="bean.Book"></jsp:useBean>
<ul>
<li>
编号:<jsp:getProperty property="id" name="book"/>
</li>
<li>
图书名称:<jsp:getProperty property="name" name="book"/>
</li>
<li>
价格:<jsp:getProperty property="price" name="book"/>
</li>
<li>
数量:<jsp:getProperty property="count" name="book"/>
</li>
<li>
作者:<jsp:getProperty property="author" name="book"/>
</li>
</ul>
</body>
</html>