package org.swj.site.dao;
import java.io.File;
import java.sql.SQLException;
import java.util.List;
import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.swj.site.domain.Staff;
import org.swj.site.util.ExcelUtil;
import com.ibatis.sqlmap.client.SqlMapExecutor;
public class StaffDao extends SqlMapClientDaoSupport
{
private ExcelUtil excelUtil;
private Staff staff;
public void setStaff(Staff staff)
{
this.staff = staff;
}
public void setExcelUtil(ExcelUtil excelUtil)
{
this.excelUtil = excelUtil;
}
@SuppressWarnings("unchecked")
public void insertStaff(File file,int sheetNum,int rowNum,int cellNum){
final List<String> result = excelUtil.readExcel(file,sheetNum,rowNum,cellNum);
getSqlMapClientTemplate().execute(new SqlMapClientCallback(){
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException
{
executor.startBatch();
for(int i=0;i<result.size();i++){
String[] strs = result.get(i).split(",");
staff.setStaffNo(strs[0]);
staff.setStaffName(strs[1]);
staff.setStaffDepartment(strs[2]);
staff.setStatus(strs[3]);
executor.insert("insertStaff",staff);
}
executor.executeBatch();
return null;
}
});
}
public void updateStaff(Staff staff){
getSqlMapClientTemplate().update("updateStaff",staff);
}
@SuppressWarnings("unchecked")
public List<Staff> selectAllStaff(Staff staff){
return getSqlMapClientTemplate().queryForList("selectStaff",staff);
}
public Staff selectStaffByNo(Staff staff){
return (Staff)getSqlMapClientTemplate().queryForObject("selectStaff",staff);
}
}
package org.swj.site.service;
import java.io.File;
import java.util.List;
import org.swj.site.dao.StaffDao;
import org.swj.site.domain.Staff;
public class StaffService
{
private StaffDao staffDao;
public void setStaffDao(StaffDao staffDao)
{
this.staffDao = staffDao;
}
public void insertStaff(File file,int sheetNum,int rowNum,int cellNum){
staffDao.insertStaff(file,sheetNum,rowNum,cellNum);
}
public void updateStaff(Staff staff){
staffDao.updateStaff(staff);
}
public List<Staff> selectAllStaff(Staff staff){
List<Staff> staffList = staffDao.selectAllStaff(staff);
return staffList;
}
public Staff selectStaffByNo(Staff staff){
return staffDao.selectStaffByNo(staff);
}
}
package org.swj.site.util;
import org.displaytag.decorator.TableDecorator;
import org.swj.site.domain.Staff;
public class Wrapper extends TableDecorator
{
public String getLink(){
StringBuffer htmlStr = new StringBuffer();
Staff staff = (Staff)getCurrentRowObject();
htmlStr.append("<a href=\"list.action?staffNo=");
htmlStr.append(staff.getStaffNo());
htmlStr.append("&action=renounce\">Renounce</a>");
return htmlStr.toString();
}
}
分享到:
相关推荐
DWR+Struts+spring+hibernate的订货系统,自己添加的dwr功能
spring+struts+hibernate+jbpm+dwr整合开发的OA办公系统源码
用户注册和登录是每个系统的必须存在的一部分,基于Dwr+Struts2+Spring+Hibernate写了一个用户登录注册系统。 其中用Dwr去进行用户注册的用户是否存在的验证。 全部业务控制交由Spring去进行处理。事务处理也...
spring+ibatis+struts2+dwr反转 加上上面的 spring+ibatis+struts2+dwr反转部分架包 在按照说明执行上面的脚本运行项目就可以看到效果了
总结,该例示注释非常详细,演示Spring托管Hibernate和Struts的Action, 以及Spring的事务声明(包括1.x与2.x的用法)与非事务声明的使用方式。 使用DWR可以方便的使用Spring托管的持久层功能。 目的:希望广大Java...
使用struts2、hibernate、spring、dwr整合的简单项目。包括级联等 注意:csdn上面显示为chm文件。该文件为.7z的压缩文件。用压缩软件可以打开的 csdn弄错了
spring+struts+hibernate+dwr+jstl做的实例.rar
一个struts2+spring+hibernate+dwr的小实例,不过木有搭建说明,不过有dwr的使用说明,至于表结构可以看映射配置文件就知道创建什么表了
spring+ibatis+struts2+dwr反转部分架包
DWR+spring+struts+hibernat整合登陆,一个简单的登陆系统,适合于初学者
struts2+hibernate+spring+dwr(用户注册)struts2+hibernate+spring+dwr(用户注册)
dwr+spring+struts+hibernate 整合在一起,代码写的不是很好,可以运行!
Spring+Struts+Hibernate+DWR集成教程.rar saivicky出品!必属精品!
Spring+Struts2+Hibernate整合框架的全部jar包,同时还有DWRjar包,MD5,放在工程中直接可用,无冲突
以用户管理为例,结合spring struts hibernate dwr jstl做的实例,struts hibernate dwr 与Spring完全结合,实现用户列表、信息增、删、改、查、维护时用户重名提示等功能,还包括页面自动转码设置(web.xml),...
EXT + DWR + Struts + Hibernate + Spring Demo
Struts2 + spring + hibernate + dwr 完美整合代码 dwr 用户注册 多级下拉联动 刷新表格.. 全部代码
struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查
我自己做的spring3+struts2+hibernate3+dwr3+spring security3+ajax请求+数据库配置权限 完整实例