/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.shi.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import com.shi.entity.Bookinfo;
import com.shi.service.BookinfoService;
import com.shi.util.PageUtil;
/**
* MyEclipse Struts
* Creation date: 10-17-2011
*
* XDoclet definition:
* @struts.action path="/bookinfo" name="bookinfoFrom" scope="request" validate="true"
*/
public class BookinfoAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
private BookinfoService bookinfoService;
public void setBookinfoService(BookinfoService bookinfoService) {
this.bookinfoService = bookinfoService;
}
/**
* 添加图书
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm bookinfoFrom = (DynaActionForm) form;// TODO Auto-generated method stub
Bookinfo bookinfo=(Bookinfo) bookinfoFrom.get("bookinfo");
if(bookinfo.getBookname()!=null&&bookinfo.getBookname()!=""){
bookinfoService.save(bookinfo);
}
return mapping.findForward("tolist");
}
/**
* 查询所有
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PageUtil page = new PageUtil();
int totalCount = (int)bookinfoService.getCount();
page.setTotalCount(totalCount);
page.setLineSize(10);
page.setTotalPage();
int currentPage = 0;
if (request.getParameter("page") == null) {
currentPage = 1;
} else {
currentPage = Integer.parseInt(request.getParameter("page"));
if (currentPage < 1) {
currentPage = 1;
}
if (currentPage > page.getTotalPage()) {
currentPage = page.getTotalPage();
}
}
page.setCurrentPage(currentPage);
List rs=bookinfoService.findAll(page);
request.setAttribute("page", page);
request.setAttribute("rs",rs);
return mapping.findForward("list");
}
/**
* 根据编号查询
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward findById(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int id=Integer.parseInt(request.getParameter("id"));
Bookinfo bookinfo=bookinfoService.findById(id);
// request.setAttribute("bookinfo", bookinfo);
DynaActionForm bookinfoFrom = (DynaActionForm) form;
bookinfoFrom.set("bookinfo",bookinfo);
return mapping.findForward("toupdate");
}
/**
* 根据书名查询
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward findByBookname(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String bookname=request.getParameter("bookname");
List rs=bookinfoService.findByBookname(bookname);
request.setAttribute("rs", rs);
return mapping.findForward("list");
}
/**
* 修改信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward merge(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm bookinfoFrom = (DynaActionForm) form;// TODO Auto-generated method stub
Bookinfo bookinfo=(Bookinfo) bookinfoFrom.get("bookinfo");
if(bookinfo.getBookname()!=null&&bookinfo.getBookname()!=""){
bookinfoService.merge(bookinfo);
}
return mapping.findForward("tolist");
}
/**
* 根据编号删除一条数据
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int id=Integer.parseInt(request.getParameter("id"));
Bookinfo bookinfo=bookinfoService.findById(id);
bookinfoService.delete(bookinfo);
return mapping.findForward("tolist");
}
/**
* 根据书名、作者、出版社进行模糊查询
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward findByLike(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm bookinfoFrom = (DynaActionForm) form;// TODO Auto-generated method stub
Bookinfo bookinfo=(Bookinfo) bookinfoFrom.get("bookinfo");
List list=bookinfoService.findByLike(bookinfo);
request.setAttribute("rs",list);
System.out.println("数量:"+list.size());
return mapping.findForward("show");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SSH1增删改查(模糊查询及分页)+SSH2增删改查(模糊查询及分页)
共102个文件
xml:18个
java:15个
class:15个
5星 · 超过95%的资源 需积分: 12 71 下载量 47 浏览量
2012-02-28
18:05:13
上传
评论 6
收藏 5.39MB ZIP 举报
温馨提示
该压缩包有2个完整SSH1+SSH2例子可以供初学者参考,友情提示导入SSH1例子时在lib包中删除asm-2.2.3.jar, SSH2例子导入运行时删除xerces-2.6.2.jar和asm-2.2.3.jar,我试过了2个例子增删改查都没有问题,配置文件我都写的很清楚有注释标明!
资源推荐
资源详情
资源评论
收起资源包目录
SSH1增删改查(模糊查询及分页)+SSH2增删改查(模糊查询及分页) (102个子文件)
BookinfoAction.class 4KB
UsersAction.class 4KB
UsersDaoHibernate.class 4KB
BookinfoDaoHibernate.class 3KB
UsersServiceImpl.class 2KB
LoginFilter.class 2KB
BookinfoServiceImpl.class 2KB
Users.class 2KB
Bookinfo.class 1KB
UtilPage.class 1KB
PageUtil.class 1KB
UsersDao.class 790B
BookinfoDao.class 632B
BookinfoService.class 158B
UsersService.class 151B
.classpath 2KB
.classpath 1KB
ojdbc14-9.2.0.5.jar 1.14MB
ojdbc14-9.2.0.5.jar 1.14MB
xwork-core-2.2.1.jar 997KB
freemarker-2.3.16.jar 860KB
struts2-core-2.2.1.jar 755KB
javassist-3.7.ga.jar 531KB
ognl-3.0.jar 224KB
commons-io-1.3.2.jar 86KB
commons-fileupload-1.2.1.jar 56KB
struts2-spring-plugin-2.2.1.jar 21KB
BookinfoAction.java 5KB
UsersDaoHibernate.java 4KB
UsersAction.java 4KB
BookinfoDaoHibernate.java 3KB
LoginFilter.java 1KB
UsersServiceImpl.java 1KB
Users.java 1KB
PageUtil.java 1KB
UtilPage.java 1KB
BookinfoServiceImpl.java 1KB
Bookinfo.java 1KB
UsersDao.java 1001B
BookinfoDao.java 808B
BookinfoService.java 130B
UsersService.java 117B
list.jsp 2KB
list.jsp 2KB
show.jsp 2KB
show.jsp 2KB
update.jsp 1KB
update.jsp 1KB
add.jsp 1KB
add.jsp 1KB
login.jsp 1KB
index.jsp 1KB
.struts-config.mex 2KB
.struts.mex 76B
.struts.mex 76B
MANIFEST.MF 39B
MANIFEST.MF 36B
.myhibernatedata 548B
.myhibernatedata 474B
.mymetadata 300B
.mymetadata 285B
.mystrutsdata 254B
org.eclipse.jdt.core.prefs 334B
org.eclipse.jdt.core.prefs 330B
.project 2KB
.project 2KB
log4j.properties 2KB
log4j.properties 2KB
log4j.properties 2KB
log4j.properties 2KB
ApplicationResources.properties 79B
ApplicationResources.properties 79B
.springBeans 467B
.springBeans 462B
struts-html.tld 72KB
spring-form.tld 71KB
struts-nested.tld 70KB
spring-form.tld 69KB
struts-logic.tld 14KB
spring.tld 13KB
spring.tld 13KB
struts-bean.tld 9KB
struts-tiles.tld 8KB
aa.umr 1KB
validator-rules.xml 13KB
web.xml 3KB
web.xml 2KB
applicationContext.xml 2KB
applicationContext.xml 2KB
applicationContext.xml 2KB
applicationContext.xml 2KB
struts-config.xml 1KB
Users.hbm.xml 1KB
Users.hbm.xml 1KB
hibernate.cfg.xml 1KB
hibernate.cfg.xml 1KB
struts.xml 1KB
struts.xml 1KB
hibernate.cfg.xml 1KB
hibernate.cfg.xml 1KB
共 102 条
- 1
- 2
andy_swc
- 粉丝: 18
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页