资源简介

采用Struts2+Hibernate技术实现的简单信息管理,具有增删该查功能,添加了二级缓存,三级缓存功能,添加了日志功能,仅为初学者学习实用

资源截图

代码片段和文件信息

package com.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.modle.Student;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.service.StudentService;
import com.serviceimpl.StudentServiceImpl;

public class StudentAction extends ActionSupport implements ModelDriven{

/**
 * 
 */
private static final long serialVersionUID = 1L;
private StudentService stu=new StudentServiceImpl();
private List list;
private int pageIndex=1;
public int getPageIndex() {
return pageIndex;
}


public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}


public List students(){

list=stu.selectList();

return list;
}


//list
public String list(){

list=students();

return list.size()>0?“ListSuccess“:ERROR;
}
//save
public String save(){

if (stu.save(student)) {
list=students();
return “editsuccess“;
}else{
return ERROR;
}

}

//select
public String listbyname(){

list=students();

return list.size()>0?“Listbyname“:ERROR;
}
public String listbyname1(){

list=stu.selectbyname(student.getSsname());
return list.size()>0?“Listbyname“:ERROR;
}


//edit
public String edit(){
System.out.println(“+++++++++action edit+++++++“);
list=students();
return list.size()>0?“editsuccess“:ERROR;
}


//modify
public String modify(){
return “modify“;
}

public String modify1(){
System.out.println(student.toString());

if(stu.update(student)){
list=students();
return “editsuccess“;
}else{
return ERROR;
}
}

//delete
public String delete(){
System.out.println(“-----------------“+student.getSsno());
if (stu.delete(student.getSsno())) {
list=students();
return “editsuccess“;
}else{
return ERROR;
}
}


//listbypage
public String listbypage(){

List students=stu.selectList();
int pageCount;//总页数
int countPrePage=3;//每页显示记录数
int studentCount;//记录数
int startSelect = 0;

studentCount=students.size();
HttpServletRequest request=ServletActionContext.getRequest();
HttpSession session=request.getSession();


session.setAttribute(“studentCount“ studentCount);

if(studentCount%countPrePage==0){//计算总页数
pageCount=studentCount/countPrePage;

}else{
pageCount=studentCount/countPrePage+1;
}


if (pageIndex==0) {
startSelect=0;

System.out.println(“1111111:“+startSelect);
}else{
startSelect=pageIndex*3-3;
}

session.setAttribute(“pageCount“ pageCount);
session.setAttribute(“

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-15 18:26  Student\
     文件        3195  2017-04-15 18:02  Student\.classpath
     文件         914  2017-03-28 10:38  Student\.project
     目录           0  2017-03-28 10:38  Student\.settings\
     文件         567  2017-03-28 10:38  Student\.settings\.jsdtscope
     文件         364  2017-03-28 10:38  Student\.settings\org.eclipse.jdt.core.prefs
     文件         573  2017-03-28 10:42  Student\.settings\org.eclipse.wst.common.component
     文件         305  2017-03-28 10:38  Student\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-03-28 10:38  Student\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-03-28 10:38  Student\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-03-28 10:38  Student\build\
     目录           0  2017-04-15 19:46  Student\build\classes\
     文件         817  2016-06-15 08:53  Student\build\classes\.classpath
     文件        1021  2016-06-15 08:53  Student\build\classes\.project
     目录           0  2017-04-15 18:02  Student\build\classes\.settings\
     文件         491  2016-06-15 08:53  Student\build\classes\.settings\.jsdtscope
     文件         357  2016-06-15 08:53  Student\build\classes\.settings\org.eclipse.jdt.core.prefs
     文件         516  2016-06-15 08:53  Student\build\classes\.settings\org.eclipse.wst.common.component
     文件         335  2016-06-15 08:53  Student\build\classes\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2016-06-15 08:53  Student\build\classes\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2016-06-15 08:53  Student\build\classes\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-04-15 18:02  Student\build\classes\com\
     目录           0  2017-04-15 18:02  Student\build\classes\com\action\
     文件        4497  2017-04-15 19:21  Student\build\classes\com\action\StudentAction.class
     目录           0  2017-04-15 18:02  Student\build\classes\com\db\
     文件         699  2017-04-15 18:02  Student\build\classes\com\db\Myhibernate.class
     目录           0  2017-04-15 18:02  Student\build\classes\com\modle\
     文件        2203  2017-04-15 18:02  Student\build\classes\com\modle\Student.class
     目录           0  2017-04-15 18:02  Student\build\classes\com\service\
     目录           0  2017-04-15 18:02  Student\build\classes\com\serviceimpl\
     文件        4789  2017-04-15 19:22  Student\build\classes\com\serviceimpl\StudentServiceImpl.class
............此处省略84个文件信息

评论

共有 条评论