JavaBeans设计原则: 1.公有类 2.无参数的构造方法 3.属性全部为私有 4.通过getter,setter实现封装 package com.bean; public class Item { private int id;//商品编号 private String name;//商品名称 private String city;//商品归属地 private int price;//商品价格 private String image;//商品图片 public Item() { // TODO Auto-generated constructor stub } 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 String getCity() { return city; } public void setCity(String city) { this.city = city; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public String getImage() { return image; } public void setImage(String image) { this.image = image; } }