资源简介

基于Struts2+Hibernate4实现报道管理系统,包含源代码和sqlserver数据库文件

资源截图

代码片段和文件信息

package com.csai.action;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.hibernate.Query;
import org.hibernate.Session;
import com.csai.POJO.Student;
import com.csai.db.HibernateUtil;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AcceptMoneyAction extends ActionSupport {
private static final long serialVersionUID = 1L;
public String studentname;
public String action;
public String matrino;
public ArrayList stuParamArray;
@Override
public String execute() throws Exception {
Session sessionHibernate=HibernateUtil.getSession();
sessionHibernate.beginTransaction();
//----查询数据操作----
String hsqlwhere=new String(““);
String hsql=new String(““);
if(“select“.equals(action)){//如果是查询操作
if(studentname!=null&&studentname.trim().length()!=0)
hsqlwhere=“where StudentName like ‘%“+studentname.trim()+“%‘ “;
if(hsqlwhere!=null&&hsqlwhere.length()!=0){
if(matrino!=null&&matrino.trim().length()!=0)
hsqlwhere+=“ and MatriNo like ‘%“+matrino.trim()+“%‘ “;
}else{
if(matrino!=null&&matrino.trim().length()!=0)
hsqlwhere=“ where MatriNo like ‘%“+matrino.trim()+“%‘ “;
}
hsql=“from Student “+hsqlwhere;
Query query=sessionHibernate.createQuery(hsql);
ArrayList stuArray =(ArrayList)query.list();
HttpServletRequest request = (HttpServletRequest)ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
request.setAttribute(“stuArray“ stuArray);
}
//----交费操作----
if(stuParamArray!=null&&“update“.equals(action)){
for(int i=0;i if(stuParamArray.get(i).getPayAmount()!=null&&stuParamArray.get(i).getPayOK()!=null&&stuParamArray.get(i).getStudentId()!=null){
String hsqlstr=“from Student where StudentId=“+stuParamArray.get(i).getStudentId();
Query query=sessionHibernate.createQuery(hsqlstr);
ArrayList stuArray =(ArrayList)query.list();
if(stuArray.size()>=1){
Student stu=stuArray.get(0);
stu.setPayAmount(stuParamArray.get(i).getPayAmount());
stu.setPayOK(stuParamArray.get(i).getPayOK());
sessionHibernate.save(stu);
}
}
}
}
sessionHibernate.getTransaction().commit();
return SUCCESS;
}
public ArrayList getStuParamArray() {
return stuParamArray;
}
public void setStuParamArray(ArrayList stuParamArray) {
this.stuParamArray = stuParamArray;
}
public String getStudentname() {
return studentname;
}
public void setStudentname(String studentname) {
this.studentname = studentname;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getMatrino() {
return matrino;
}
public void setMatrino(String matrino) {
this.matrino = matrino;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-03-13 17:34  ch16\
     文件         834  2011-08-31 13:51  ch16\.classpath
     文件        1037  2011-08-31 13:51  ch16\.project
     目录           0  2013-03-13 17:34  ch16\.settings\
     文件         503  2011-08-31 13:51  ch16\.settings\.jsdtscope
     文件         395  2011-08-31 13:51  ch16\.settings\org.eclipse.jdt.core.prefs
     文件         442  2011-08-31 13:51  ch16\.settings\org.eclipse.wst.common.component
     文件         345  2011-08-31 13:51  ch16\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2011-08-31 13:51  ch16\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2011-08-31 13:51  ch16\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2013-03-13 17:34  ch16\WebContent\
     目录           0  2013-03-13 17:34  ch16\WebContent\meta-INF\
     文件          39  2011-08-31 13:51  ch16\WebContent\meta-INF\MANIFEST.MF
     目录           0  2013-03-13 17:34  ch16\WebContent\WEB-INF\
     目录           0  2013-03-13 17:34  ch16\WebContent\WEB-INF\lib\
     文件      445288  2007-01-13 00:28  ch16\WebContent\WEB-INF\lib\antlr-2.7.7.jar
     文件       57963  2011-03-04 21:13  ch16\WebContent\WEB-INF\lib\classmate-0.5.4.jar
     文件      559366  2005-11-22 12:09  ch16\WebContent\WEB-INF\lib\commons-collections-3.1.jar
     文件       59590  2011-01-31 10:40  ch16\WebContent\WEB-INF\lib\commons-fileupload-1.2.2.jar
     文件      159509  2011-01-31 10:40  ch16\WebContent\WEB-INF\lib\commons-io-2.0.1.jar
     文件      279193  2010-10-19 15:31  ch16\WebContent\WEB-INF\lib\commons-lang-2.5.jar
     文件       60686  2010-10-13 10:51  ch16\WebContent\WEB-INF\lib\commons-logging-1.1.1.jar
     文件       44598  2010-10-15 18:23  ch16\WebContent\WEB-INF\lib\commons-logging-api-1.1.jar
     文件      313898  2005-08-01 21:27  ch16\WebContent\WEB-INF\lib\dom4j-1.6.1.jar
     文件      880993  2010-10-15 18:21  ch16\WebContent\WEB-INF\lib\freemarker-2.3.16.jar
     文件       71283  2010-03-09 10:41  ch16\WebContent\WEB-INF\lib\hibernate-commons-annotations-3.2.0.Final.jar
     文件     4202169  2011-08-17 21:10  ch16\WebContent\WEB-INF\lib\hibernate-core-4.0.0.CR1.jar
     文件      102661  2011-06-14 21:42  ch16\WebContent\WEB-INF\lib\hibernate-jpa-2.0-api-1.0.1.Final.jar
     文件       70305  2011-05-10 21:09  ch16\WebContent\WEB-INF\lib\jandex-1.0.0.Beta7.jar
     文件      633312  2010-11-23 01:21  ch16\WebContent\WEB-INF\lib\javassist-3.12.0.GA.jar
     文件       47399  2011-02-16 09:00  ch16\WebContent\WEB-INF\lib\jboss-logging-3.0.0.Beta5.jar
............此处省略94个文件信息

评论

共有 条评论