Struts+Spring+Hibernate真正入门级实例(五)
来源:互联网 发布:建筑三维建模软件 编辑:程序博客网 时间:2024/05/17 01:35
People.hbm.xml
xml version="1.0" encoding="utf-8"?>
DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain">
<class name="People" table="people" >
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="increment">generator>
id>
<property name="name" type="java.lang.String">
<column name="name" length="100" />
property>
<property name="location" type="java.lang.String">
<column name="location" length="100" />
property>
class>
hibernate-mapping>
DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="domain">
<class name="People" table="people" >
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="increment">generator>
id>
<property name="name" type="java.lang.String">
<column name="name" length="100" />
property>
<property name="location" type="java.lang.String">
<column name="location" length="100" />
property>
class>
hibernate-mapping>
People.java
package domain;
/** *//**
* People generated by MyEclipse - Hibernate Tools
*/
public class People extends AbstractPeople implements java.io.Serializable ...{
// Constructors
/** *//** default constructor */
public People() ...{
}
/** *//** full constructor */
public People(String name, String location) ...{
super(name, location);
}
}
/** *//**
* People generated by MyEclipse - Hibernate Tools
*/
public class People extends AbstractPeople implements java.io.Serializable ...{
// Constructors
/** *//** default constructor */
public People() ...{
}
/** *//** full constructor */
public People(String name, String location) ...{
super(name, location);
}
}
IService.java
package service;
import java.util.List;
public interface IService ...{
public void savePeople(Object obj);
public List listPeople(int firstRow,int lastRow,String hql);
public List listPeople();
public void deletePeople(Integer id);
public Object getPeople(Integer id);
public void editPeople(Object obj);
public List searchPeople(String hql);
public List searchPeople(int firstRow,int lastRow,String hql);
}
import java.util.List;
public interface IService ...{
public void savePeople(Object obj);
public List listPeople(int firstRow,int lastRow,String hql);
public List listPeople();
public void deletePeople(Integer id);
public Object getPeople(Integer id);
public void editPeople(Object obj);
public List searchPeople(String hql);
public List searchPeople(int firstRow,int lastRow,String hql);
}
StudentManagerImpl.java
package service;
import java.util.ArrayList;
import java.util.List;
import dao.IDAO;
import domain.People;
public class StudentManagerImpl implements IService ...{
private IDAO studentDAO;
public void savePeople(Object obj) ...{
if(obj instanceof People)...{
People people=(People)obj;
studentDAO.save(people);
}
}
public List searchPeople(String hql)...{
return studentDAO.searchPeople(hql);
}
public List searchPeople(int firstRow,int lastRow,String hql)...{
return studentDAO.searchPeople(firstRow, lastRow, hql);
}
public List listPeople(int firstRow,int lastRow,String hql)...{
List peopleList=new ArrayList();
peopleList=studentDAO.list(firstRow,lastRow,hql);
return peopleList;
}
public List listPeople()...{
return studentDAO.list();
}
public void editPeople(Object obj)...{
if(obj instanceof People)...{
People people=(People)obj;
studentDAO.editPeople(people);
}
}
public Object getPeople(Integer id)...{
return studentDAO.getPeople(id);
}
public void deletePeople(Integer id)...{
studentDAO.delete(this.getPeople(id));
}
public IDAO getStudentDAO() ...{
return studentDAO;
}
public void setStudentDAO(IDAO studentDAO) ...{
this.studentDAO = studentDAO;
}
}
import java.util.ArrayList;
import java.util.List;
import dao.IDAO;
import domain.People;
public class StudentManagerImpl implements IService ...{
private IDAO studentDAO;
public void savePeople(Object obj) ...{
if(obj instanceof People)...{
People people=(People)obj;
studentDAO.save(people);
}
}
public List searchPeople(String hql)...{
return studentDAO.searchPeople(hql);
}
public List searchPeople(int firstRow,int lastRow,String hql)...{
return studentDAO.searchPeople(firstRow, lastRow, hql);
}
public List listPeople(int firstRow,int lastRow,String hql)...{
List peopleList=new ArrayList();
peopleList=studentDAO.list(firstRow,lastRow,hql);
return peopleList;
}
public List listPeople()...{
return studentDAO.list();
}
public void editPeople(Object obj)...{
if(obj instanceof People)...{
People people=(People)obj;
studentDAO.editPeople(people);
}
}
public Object getPeople(Integer id)...{
return studentDAO.getPeople(id);
}
public void deletePeople(Integer id)...{
studentDAO.delete(this.getPeople(id));
}
public IDAO getStudentDAO() ...{
return studentDAO;
}
public void setStudentDAO(IDAO studentDAO) ...{
this.studentDAO = studentDAO;
}
}
Character.java
package util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.RequestProcessor;
public class Character extends RequestProcessor...{
protected boolean processRoles(HttpServletRequest request,
HttpServletResponse response, ActionMapping mapping)
throws IOException, ServletException ...{
return super.processRoles(request, response, mapping);
}
protected void processContent(HttpServletRequest request,
HttpServletResponse response) ...{
try ...{
request.setCharacterEncoding("gb2312");
System.out.println(request.getCharacterEncoding());
} catch (UnsupportedEncodingException e) ...{
e.printStackTrace();
}
super.processContent(request, response);
}
}
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.RequestProcessor;
public class Character extends RequestProcessor...{
protected boolean processRoles(HttpServletRequest request,
HttpServletResponse response, ActionMapping mapping)
throws IOException, ServletException ...{
return super.processRoles(request, response, mapping);
}
protected void processContent(HttpServletRequest request,
HttpServletResponse response) ...{
try ...{
request.setCharacterEncoding("gb2312");
System.out.println(request.getCharacterEncoding());
} catch (UnsupportedEncodingException e) ...{
e.printStackTrace();
}
super.processContent(request, response);
}
}
PageSupport.java
package util;
public class PageSupport ...{
int thispage = 0;// 当前页数
int pagesize = 5;// 每页最大记录数
int firstpage = 0;// 记录开始的位置
int lastpage = 0;// 记录结束的位置
int pagetotal = 0;// 总记录数
int pagenums = 0;// 总页数
public PageSupport(String page)...{
if(page==null||page.equals(""))...{
thispage=1;
}
else...{
thispage=Integer.parseInt(page);
}
}
public int calcFirstPage()...{
pagenums = pagetotal / pagesize;
if (pagetotal % pagesize != 0)...{
pagenums = pagenums + 1;
}
if (thispage > pagenums)
thispage = pagenums;
else if(thispage<=0)...{
thispage=1;
}
if(thispage<=1)...{
firstpage=1;
}
else...{
firstpage = (thispage-1) * pagesize+1;
}
return this.firstpage;
}
public int calcLastPage()...{
return this.pagesize;
}
public int getFirstpage() ...{
return firstpage;
}
public void setFirstpage(int firstpage) ...{
this.firstpage = firstpage;
}
public int getLastpage() ...{
return lastpage;
}
public void setLastpage(int lastpage) ...{
this.lastpage = lastpage;
}
public int getPagenums() ...{
return pagenums;
}
public void setPagenums(int pagenums) ...{
this.pagenums = pagenums;
}
public int getPagesize() ...{
return pagesize;
}
public void setPagesize(int pagesize) ...{
this.pagesize = pagesize;
}
public int getPagetotal() ...{
return pagetotal;
}
public void setPagetotal(int pagetotal) ...{
this.pagetotal = pagetotal;
}
public int getThispage() ...{
return thispage;
}
public void setThispage(int thispage) ...{
this.thispage = thispage;
}
}
public class PageSupport ...{
int thispage = 0;// 当前页数
int pagesize = 5;// 每页最大记录数
int firstpage = 0;// 记录开始的位置
int lastpage = 0;// 记录结束的位置
int pagetotal = 0;// 总记录数
int pagenums = 0;// 总页数
public PageSupport(String page)...{
if(page==null||page.equals(""))...{
thispage=1;
}
else...{
thispage=Integer.parseInt(page);
}
}
public int calcFirstPage()...{
pagenums = pagetotal / pagesize;
if (pagetotal % pagesize != 0)...{
pagenums = pagenums + 1;
}
if (thispage > pagenums)
thispage = pagenums;
else if(thispage<=0)...{
thispage=1;
}
if(thispage<=1)...{
firstpage=1;
}
else...{
firstpage = (thispage-1) * pagesize+1;
}
return this.firstpage;
}
public int calcLastPage()...{
return this.pagesize;
}
public int getFirstpage() ...{
return firstpage;
}
public void setFirstpage(int firstpage) ...{
this.firstpage = firstpage;
}
public int getLastpage() ...{
return lastpage;
}
public void setLastpage(int lastpage) ...{
this.lastpage = lastpage;
}
public int getPagenums() ...{
return pagenums;
}
public void setPagenums(int pagenums) ...{
this.pagenums = pagenums;
}
public int getPagesize() ...{
return pagesize;
}
public void setPagesize(int pagesize) ...{
this.pagesize = pagesize;
}
public int getPagetotal() ...{
return pagetotal;
}
public void setPagetotal(int pagetotal) ...{
this.pagetotal = pagetotal;
}
public int getThispage() ...{
return thispage;
}
public void setThispage(int thispage) ...{
this.thispage = thispage;
}
}
- Struts+Spring+Hibernate真正入门级实例(五)
- Struts+Spring+Hibernate真正入门级实例
- Struts+Spring+Hibernate真正入门级实例
- Struts+Spring+Hibernate真正入门级实例
- Struts+Spring+Hibernate真正入门级实例
- Struts+Spring+Hibernate真正入门级实例
- Struts+Spring+Hibernate真正入门级实例(一)
- Struts+Spring+Hibernate真正入门级实例(二)
- Struts+Spring+Hibernate真正入门级实例(三)
- Struts+Spring+Hibernate真正入门级实例(四)
- Struts+Spring+Hibernate真正入门级实例(六)
- Struts+Spring+Hibernate入门实例
- Struts+Hibernate入门实例
- struts+hibernate+spring简单实例
- struts+spring+hibernate配置实例
- struts+spring+hibernate配置实例
- struts+spring+hibernate快速入门
- struts+spring+hibernate快速入门
- 通过本地Excel文件更新远程SQL SERVER表中数据
- 如何指定Gridview选中某一列中等于特定值的行
- Struts+Spring+Hibernate真正入门级实例(四)
- 魔兽世界用迅闪更新的问题
- 雅虎公司C#笔试题
- Struts+Spring+Hibernate真正入门级实例(五)
- 用java调用oracle存储过程总结
- C#字符串处理积累(一)
- Oracle 10G -- 增强的CONNECT BY子句
- Struts+Spring+Hibernate真正入门级实例(六)
- C#指定窗口显示位置
- [转]MODBUS通信协议详解〔http://suncilang.21ic.org/user1/245/archives/2007/37664.html〕
- 两个listbox控件之间的(Mondify By LiFuyun)秘密-----------------个人学习心得
- 努力