求struts2+spring+hibernate实现增删改查的例子 不要求太大 数据库要求MySql 20
展开全部
采用struts2+spring2.5+hibernate3.3
下面是增的实现:
package com.firstssh.action;
import java.util.List;
import java.util.Map;
import com.firstssh.model.Book;
import com.firstssh.service.IBookService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class AddBookAction extends ActionSupport {
private String bookname;
private String author;
private String price;
private IBookService bookService;
public String execute() throws Exception {
Book book=new Book();
book.setBookname(bookname);
book.setAuthor(author);
book.setPrice(price);
if(bookService.addBook(book)){
return SUCCESS;
}else{
return INPUT;
}
}
public IBookService getBookService() {
return bookService;
}
public void setBookService(IBookService bookService) {
this.bookService = bookService;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
}
等等。。发你邮箱了。
下面是增的实现:
package com.firstssh.action;
import java.util.List;
import java.util.Map;
import com.firstssh.model.Book;
import com.firstssh.service.IBookService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class AddBookAction extends ActionSupport {
private String bookname;
private String author;
private String price;
private IBookService bookService;
public String execute() throws Exception {
Book book=new Book();
book.setBookname(bookname);
book.setAuthor(author);
book.setPrice(price);
if(bookService.addBook(book)){
return SUCCESS;
}else{
return INPUT;
}
}
public IBookService getBookService() {
return bookService;
}
public void setBookService(IBookService bookService) {
this.bookService = bookService;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
}
等等。。发你邮箱了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询