package com.action;
import java.util.List;
import com.dao.ClassDao;
import com.dao.StudentDao;
import com.entity.SshClass;
import com.entity.SshStudent;
public class StudentAction extends BaseAction{
private StudentDao studentDao;
private ClassDao classDao;
private List<SshStudent> listStudent;
private List<SshClass> listClass;
//条件查询的提交值
private Integer sid;//这里用Integer因为int默认为0,会显示在页面中,Integer默认为null
private String sname;
private int cid;
//分页
private int currentPage;
private int pageSize=3;
private int pageCount;
private int rows;
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public void setSid(Integer sid) {
this.sid = sid;
}
public void setSname(String sname) {
this.sname = sname;
}
public void setCid(int cid) {
this.cid = cid;
}
public List<SshStudent> getListStudent() {
return listStudent;
}
public List<SshClass> getListClass() {
return listClass;
}
public void setStudentDao(StudentDao studentDao) {
this.studentDao = studentDao;
}
public void setClassDao(ClassDao classDao) {
this.classDao = classDao;
}
//条件查询
public String execute(){
String hql = "from SshStudent where 1=1";
if(sid != null){
hql = hql+" and sid="+sid;
}
if(sname !="" && sname != null){
hql = hql+" and sname like '%"+sname+"%'";
}
if(cid != -1 && cid != 0){
hql = hql +" and cid ="+cid;
}
String h = "select count(*) "+hql;
rows = studentDao.getRows(h);
if(currentPage == 0){
currentPage = 1;
}
if(rows%pageSize == 0){
pageCount = rows/pageSize;
}else{
pageCount = rows/pageSize+1;
}
request.put("pageCount", pageCount);
request.put("sid", sid);
request.put("sname", sname);
request.put("cid", cid);
request.put("currentPage", currentPage);
listStudent = studentDao.findAll(hql, currentPage, pageSize);
listClass = classDao.findAll("from SshClass");
return SUCCESS;
}
//删除一个学生
public String delete(){
SshStudent stu = studentDao.findById(sid);
studentDao.delete(stu);
sid = null;
return execute();
}
//添加学生
public String add(){
listClass = classDao.findAll("from SshClass");
return "add";
}
public String add1(){
SshClass c = classDao.findById(cid);
SshStudent stu = new SshStudent(c, sname);
studentDao.save(stu);
sid = null;
sname = "";
cid = -1;
return execute();
}
//修改学生
public String update(){
SshStudent stu = studentDao.findById(sid);
request.put("sid", sid);
sname = stu.getSname();
cid = stu.getSshClass().getCid();
request.put("sname", sname);
request.put("cid", cid);
return "update";
}
public String update1(){
SshClass c = classDao.findById(cid);
SshStudent stu = studentDao.findById(sid);
stu.setSname(sname);
stu.setSshClass(c);
studentDao.update(stu);
sid = null;
sname = "";
cid = -1;
return execute();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ssh三大框架增删改查,严格分层
共98个文件
jar:50个
class:11个
xml:11个
3星 · 超过75%的资源 需积分: 10 36 下载量 161 浏览量
2014-12-09
21:03:31
上传
评论
收藏 15.2MB RAR 举报
温馨提示
ssh三大框架增删改查完美版,分页,条件查询,代码严格分层,新手可以学习一下。
资源推荐
资源详情
资源评论
收起资源包目录
ssh_perfect.rar (98个子文件)
ssh_perfect
.springBeans 462B
.myhibernatedata 526B
.settings
org.eclipse.jdt.core.prefs 330B
src
com
dao
ClassDao.java 110B
BaseDao.java 477B
StudentDao.java 116B
impl
StudentDaoImpl.java 2KB
ClassDaoImpl.java 1KB
action
BaseAction.java 603B
StudentAction.java 3KB
entity
SshStudent.hbm.xml 808B
SshStudent.java 827B
SshClass.java 982B
SshClass.hbm.xml 881B
struts.xml 466B
.struts.mex 636B
hibernate.cfg.xml 997B
applicationContext.xml 2KB
.project 2KB
WebRoot
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 1KB
classes
com
dao
ClassDao.class 209B
BaseDao.class 816B
StudentDao.class 215B
impl
StudentDaoImpl$1.class 2KB
ClassDaoImpl.class 2KB
StudentDaoImpl.class 3KB
StudentDaoImpl$2.class 2KB
action
StudentAction.class 4KB
BaseAction.class 900B
entity
SshStudent.hbm.xml 808B
SshClass.hbm.xml 881B
SshStudent.class 1KB
SshClass.class 1KB
struts.xml 466B
.struts.mex 636B
hibernate.cfg.xml 997B
applicationContext.xml 2KB
lib
log4j-1.2.14.jar 359KB
freemarker-2.3.15.jar 859KB
commons-collections-3.1.jar 546KB
hibernate-annotations.jar 273KB
com.springsource.org.apache.commons.logging-1.1.1.jar 60KB
org.springframework.core-3.0.1.RELEASE-A.jar 347KB
dom4j-1.6.1.jar 307KB
org.springframework.web.servlet-3.0.1.RELEASE-A.jar 389KB
ejb3-persistence.jar 49KB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
org.springframework.web.portlet-3.0.1.RELEASE-A.jar 169KB
org.springframework.aop-3.0.1.RELEASE-A.jar 313KB
cglib-2.2.jar 272KB
org.springframework.web-3.0.1.RELEASE-A.jar 352KB
com.springsource.org.codehaus.jackson.mapper-1.0.0.jar 264KB
persistence.jar 69KB
com.springsource.org.apache.log4j-1.2.15.jar 387KB
org.springframework.asm-3.0.1.RELEASE-A.jar 52KB
ognl-2.7.3.jar 234KB
org.springframework.transaction-3.0.1.RELEASE-A.jar 223KB
org.springframework.orm-3.0.1.RELEASE-A.jar 324KB
org.springframework.expression-3.0.1.RELEASE-A.jar 152KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
org.springframework.aspects-3.0.1.RELEASE-A.jar 29KB
javassist-3.9.0.GA.jar 583KB
hibernate-commons-annotations.jar 65KB
org.springframework.jdbc-3.0.1.RELEASE-A.jar 369KB
struts2-spring-plugin-2.1.8.1.jar 16KB
xwork-core-2.1.6.jar 1.49MB
commons-fileupload-1.2.1.jar 56KB
slf4j-api-1.5.8.jar 23KB
org.springframework.oxm-3.0.1.RELEASE-A.jar 56KB
ehcache-1.2.3.jar 203KB
struts2-core-2.1.8.1.jar 738KB
com.springsource.org.apache.commons.httpclient-3.1.0.jar 301KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar 5KB
org.springframework.context-3.0.1.RELEASE-A.jar 642KB
commons-io-1.3.2.jar 86KB
slf4j-log4j12-1.5.8.jar 9KB
org.springframework.instrument-3.0.1.RELEASE-A.jar 2KB
jta-1.1.jar 13KB
hibernate-validator.jar 61KB
com.springsource.org.apache.commons.fileupload-1.2.0.jar 53KB
hibernate-entitymanager.jar 116KB
org.springframework.web.struts-3.0.1.RELEASE-A.jar 524KB
mysql-connector-java-5.0.7-bin.jar 524KB
antlr-2.7.6.jar 433KB
org.springframework.beans-3.0.1.RELEASE-A.jar 535KB
hibernate3.jar 2.31MB
spring.tld 17KB
spring-form.tld 69KB
main.jsp 3KB
js
jquery-1.4.2.js 160KB
login.jsp 1KB
add.jsp 1KB
index.jsp 834B
update.jsp 1KB
.mymetadata 306B
.classpath 5KB
.myeclipse
共 98 条
- 1
资源评论
- momibao95592017-02-24好像没有数据库啊????
rongxuxiang
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功