资源简介

基于 struts2 spring3.0 hibernate的图书管理系统,数据库运用mysql spring使用的是注解配置,hibernate的配置同样使用的注解。前台是简单的jsp。只是一个简单的例子,共享出来,方便大家了解三大框架的配置,和注解的使用

资源截图

代码片段和文件信息

package com.xinyue.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.xinyue.model.Book;
import com.xinyue.model.Booktype;
import com.xinyue.model.User;
import com.xinyue.service.BookManage;
import com.xinyue.service.BooktypeManage;
import com.xinyue.service.UserManage;

public class BookAction extends ActionSupport implements SessionAware {

/**
 * 
 */
// private Mapject> seesion;

private String typeName;
public String getTypeName() {
return typeName;
}

public void setTypeName(String typeName) {
this.typeName = typeName;
}

private Mapject> session;
private static final long serialVersionUID = 1L;
private Integer typeid;

public Integer getTypeid() {
return typeid;
}

public void setTypeid(Integer typeid) {
this.typeid = typeid;
}

private Book book;

private List listBooktype;

public List getListBooktype() {
return listBooktype;
}

public void setListBooktype(List listBooktype) {
this.listBooktype = listBooktype;
}

public Book getBook() {
return book;
}

public void setBook(Book book) {
this.book = book;
}

private String author;
private BookManage bookManage;
private String bookName;
// private Booktype booktype;
private Integer id;
private String publicer;
private BooktypeManage booktypeManage;

public BooktypeManage getBooktypeManage() {
return booktypeManage;
}

@Autowired
public void setBooktypeManage(BooktypeManage booktypeManage) {
this.booktypeManage = booktypeManage;
}

public Integer getBooktypeId() {
return booktypeId;
}

public void setBooktypeId(Integer booktypeId) {
this.booktypeId = booktypeId;
}

private Integer booktypeId;

private List listBook;

private User user;

private UserManage userManage;

public String addBook() {
System.out.println(id);
if(-1==id){
System.out.println(“ERROR“);
return ERROR;
}
Booktype booktype1 = booktypeManage.findById(id);
Book book = new Book();
book.setAuthor(author);
book.setBookName(bookName);
book.setBooktype(booktype1);
book.setPublicer(publicer);
bookManage.save(book);

return SUCCESS;
}

public String borrowBook() {

Book book = bookManage.findById(id);
Mapject> session = ActionContext.getContext().getSession();
String name = (String) session.get(“user“);

User user1 = userManage.findByName(name);
int count = user1.getCount();

user1.setCount(++count);
session.put(“count“count);
userManage.save(user1);
book.setUser(user1);
bookManage.update(book);

return SUCCESS;
}

public String getAuthor() {
return author;
}

public BookManage getBoo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3946  2012-06-16 15:22  LibrarySystem\.classpath

     文件        312  2012-06-19 09:56  LibrarySystem\.mymetadata

     文件        240  2012-06-16 15:21  LibrarySystem\.mystrutsdata

     文件       1832  2012-06-16 15:29  LibrarySystem\.project

     文件        335  2012-06-16 15:23  LibrarySystem\.settings\com.genuitec.eclipse.persistence.jpa.prefs

     文件        330  2012-06-16 15:20  LibrarySystem\.settings\org.eclipse.jdt.core.prefs

     文件        474  2012-06-16 15:21  LibrarySystem\.springBeans

     文件       4040  2012-06-18 15:27  LibrarySystem\src\.struts.mex

     文件       6332  2012-06-19 21:23  LibrarySystem\src\com\xinyue\action\BookAction.java

     文件       2126  2012-06-18 18:35  LibrarySystem\src\com\xinyue\action\BooktypeAction.java

     文件       3538  2012-06-19 20:45  LibrarySystem\src\com\xinyue\action\UserAction.java

     文件       4692  2012-06-16 15:31  LibrarySystem\src\com\xinyue\dao\IBookDAO.java

     文件       4695  2012-06-18 12:29  LibrarySystem\src\com\xinyue\dao\IBooktypeDAO.java

     文件       4679  2012-06-16 15:31  LibrarySystem\src\com\xinyue\dao\IUserDAO.java

     文件       8984  2012-06-16 21:58  LibrarySystem\src\com\xinyue\daoimp\BookDAO.java

     文件       8959  2012-06-18 12:38  LibrarySystem\src\com\xinyue\daoimp\BooktypeDAO.java

     文件       9011  2012-06-16 21:58  LibrarySystem\src\com\xinyue\daoimp\UserDAO.java

     文件       2201  2012-06-19 00:23  LibrarySystem\src\com\xinyue\model\Book.java

     文件       1588  2012-06-18 20:41  LibrarySystem\src\com\xinyue\model\Booktype.java

     文件       1972  2012-06-18 18:51  LibrarySystem\src\com\xinyue\model\User.java

     文件        492  2012-06-18 15:03  LibrarySystem\src\com\xinyue\service\BookManage.java

     文件        380  2012-06-18 12:13  LibrarySystem\src\com\xinyue\service\BooktypeManage.java

     文件        442  2012-06-18 18:50  LibrarySystem\src\com\xinyue\service\UserManage.java

     文件       1131  2012-06-18 15:03  LibrarySystem\src\com\xinyue\serviceimp\BookManageimp.java

     文件        942  2012-06-18 12:38  LibrarySystem\src\com\xinyue\serviceimp\BooktypeManageimp.java

     文件       1338  2012-06-18 18:51  LibrarySystem\src\com\xinyue\serviceimp\UserManageimp.java

     文件       1070  2012-06-17 16:43  LibrarySystem\src\meta-INF\persistence.xml

     文件       5588  2012-06-19 13:42  LibrarySystem\src\struts.xml

     文件        829  2012-06-17 16:22  LibrarySystem\WebRoot\add.jsp

     文件        829  2012-06-17 16:22  LibrarySystem\WebRoot\addSuccess.jsp

............此处省略122个文件信息

评论

共有 条评论