日期:2014-05-19 浏览次数:20724 次
package com.jin.action; import java.util.ArrayList; import java.util.List; import com.jin.pojo.Book; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionContext; public class LoginAction implements Action { private List<Book> books; public List<Book> getBooks() { return books; } public void setBooks(List<Book> books) { this.books = books; } public String execute() throws Exception { List<Book> list = new ArrayList(); Book bk1 = new Book(); bk1.setName("Linux实战指南"); bk1.setPrice(52.5); Book bk2 = new Book(); bk2.setName("JSP/Servlet实战"); bk2.setPrice(60.0); Book bk3 = new Book(); bk3.setName("Spring3.0全面解析"); bk3.setPrice(44.5); list.add(bk1); list.add(bk2); list.add(bk3); this.setBooks(list); return Action.SUCCESS; } }
package com.jin.pojo; import java.io.Serializable; public class Book implements Serializable { private static final long serialVersionUID = -7637363221122361901L; private String name; private double price; 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; } }