日期:2014-05-17 浏览次数:20580 次
package action; import hibernate.Book; import java.util.List; import Imp.BookServiceHibernateImpl; import Interface.BookService; import com.opensymphony.xwork2.ActionSupport; public class BookAction extends ActionSupport { private BookService service; private String title; private List<Book> list; // 省略对应bookname和list的getter和setter public BookAction() { service = new BookServiceHibernateImpl(); } // 该方法实现书名的插入操作 public String addBook() { Book book = new Book(); book.settitle(title); service.add(book); return SUCCESS; } //该方法实现书名的删除操作 public String delBook() { Book book = new Book(); book.settitle(title); service.del(book); return SUCCESS; } // 该方法实现所有书名的查询操作 public String ListBook() { list = service.find(); return SUCCESS; } }
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>ADD BOOK Success</title> </head> <body> <s:select name="rtnlist" list="list" listKey="id" listValue="id+'__'title"></s:select> </body> </html>