Struts2、Spring和Hibernate应用实例2
来源:互联网 发布:网络4g十是什么意思 编辑:程序博客网 时间:2024/04/30 03:43
Struts 1.x | Stuts 2.0 | |
接口 | 必须继承org.apache.struts.action.Action或者其子类 | 无须继承任何类型或实现任何接口 |
表单数据 | 表单数据封装在FormBean中 | 表单数据包含在Action中,通过Getter和Setter获取 |
package com.sterning.books.web.actions;import java.util.Collection;import com.sterning.books.model.Books;import com.sterning.books.services.iface.IBooksService;import com.sterning.commons.AbstractAction;import com.sterning.commons.Pager;import com.sterning.commons.PagerService;public class BooksAction extends AbstractAction {private IBooksService booksService;private PagerService pagerService;private Books book;private Pager pager;protected Collection availableItems;protected String currentPage;protected String pagerMethod;protected String totalRows;protected String bookId;protected String queryName;protected String queryValue;protected String searchName;protected String searchValue;protected String queryMap;public String list() throws Exception {if(queryMap ==null||queryMap.equals("")){}else{String[] str=queryMap.split("~");this.setQueryName(str[0]);this.setQueryValue(str[1]);}System.out.println("asd"+this.getQueryValue());int totalRow=booksService.getRows(this.getQueryName(),this.getQueryValue());pager=pagerService.getPager(this.getCurrentPage(), this.getPagerMethod(), totalRow);this.setCurrentPage(String.valueOf(pager.getCurrentPage()));this.setTotalRows(String.valueOf(totalRow));availableItems=booksService.getBooks(this.getQueryName(),this.getQueryValue(),pager.getPageSize(), pager.getStartRow());this.setQueryName(this.getQueryName());this.setQueryValue(this.getQueryValue());this.setSearchName(this.getQueryName());this.setSearchValue(this.getQueryValue());return SUCCESS;}public String load() throws Exception {if(bookId!=null)book = booksService.getBook(bookId);else bookId=booksService.getMaxID();return SUCCESS;}public String save() throws Exception {if(this.getBook().getBookPrice().equals("")){this.getBook().setBookPrice("0.0");}String id=this.getBook().getBookId();Books book=booksService.getBook(id);if(book == null)booksService.addBook(this.getBook());else booksService.updateBook(this.getBook());this.setQueryName(this.getQueryName());this.setQueryValue(this.getQueryValue());if(this.getQueryName()==null||this.getQueryValue()==null||this.getQueryName().equals("")||this.getQueryValue().equals("")){}else{queryMap=this.getQueryName()+"~"+this.getQueryValue();}return SUCCESS;}public String delete() throws Exception {booksService.deleteBook(this.getBookId());if(this.getQueryName()==null||this.getQueryValue()==null||this.getQueryName().equals("")||this.getQueryValue().equals("")){}else{queryMap=this.getQueryName()+"~"+this.getQueryValue();}return SUCCESS;}public Books getBook() {return book;}public void setBook(Books book) {this.book = book;}public IBooksService getBooksService() {return booksService;}public void setBooksService(IBooksService booksService) {this.booksService = booksService;}public Collection getAvailableItems() {return availableItems;}public String getCurrentPage() {return currentPage;}public void setCurrentPage(String currentPage) {this.currentPage = currentPage;}public String getPagerMethod() {return pagerMethod;}public void setPagerMethod(String pagerMethod) {this.pagerMethod = pagerMethod;}public Pager getPager() {return pager;}public void setPager(Pager pager) {this.pager = pager;}public String getTotalRows() {return totalRows;}public void setTotalRows(String totalRows) {this.totalRows = totalRows;}public String getBookId() {return bookId;}public void setBookId(String bookId) {this.bookId = bookId;}public String getQueryName() {return queryName;}public void setQueryName(String queryName) {this.queryName = queryName;}public String getQueryValue() {return queryValue;}public void setQueryValue(String queryValue) {this.queryValue = queryValue;}public String getSearchName() {return searchName;}public void setSearchName(String searchName) {this.searchName = searchName;}public String getSearchValue() {return searchValue;}public void setSearchValue(String searchValue) {this.searchValue = searchValue;}public String getQueryMap() {return queryMap;}public void setQueryMap(String queryMap) {this.queryMap = queryMap;}public PagerService getPagerService() {return pagerService;}public void setPagerService(PagerService pagerService) {this.pagerService = pagerService;}}
com.sterning.books.web.actions.BookAction.java com.sterning.books.web.actions.BooksAction-save-validation.xml
- Struts2、Spring和Hibernate应用实例2
- Struts2、Spring和Hibernate应用实例2
- Struts2和Spring和Hibernate应用实例
- Struts2和Spring和Hibernate应用实例
- Struts2、Spring和Hibernate应用实例1
- Struts2、Spring和Hibernate应用实例1
- Struts2、Spring和Hibernate应用实例3
- Struts2、Spring和Hibernate应用实例
- Struts2、Spring和Hibernate应用实例
- Struts2、Spring和Hibernate应用实例
- Struts2、Spring和Hibernate应用实例
- Struts2、Spring和Hibernate应用实例
- Struts2、Spring和Hibernate实例3
- struts2+spring+hibernate实例
- Struts2+Spring+hibernate整合实例
- struts2整合 spring应用实例
- struts2整合 spring应用实例
- struts2整合spring应用实例
- 微软同步框架(MSF)入门之三--分析生成的同步类文件
- session 丢失
- __declspec(dllimport) 到底有什么用
- 第一篇
- jquery学习笔记-jquery实现无刷新联动
- Struts2、Spring和Hibernate应用实例2
- JSF FacesContext 详解
- DataList 分页的实现
- IT女白领突击怀孕避裁员
- 2109 Power of Cryptography 纯水
- 有效积累
- 序列化概述
- Struts2、Spring和Hibernate实例3
- linux内核网络栈代码分析