1.创建Book封装图书信息:Book
public class Book { private String id; private String name; public Book(String id, String name) { this.id = id; this.name = name; } public Book() { } 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; } }
2.创建BookDB,模拟数据库,里面保存图书
public class BookDB { private static Map<String ,Book> map = new LinkedHashMap<String, Book>(); static { map.put("1",new Book("1","java web")); map.put("2",new Book("2","jdbc")); map.put("3",new Book("3","java 基础")); map.put("4",new Book("4","struts框架")); map.put("5",new Book("5