package com.atguigu.ssh.actions;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Map;
import org.apache.struts2.interceptor.RequestAware;
import com.atguigu.ssh.entities.Employee;
import com.atguigu.ssh.service.DepartmentService;
import com.atguigu.ssh.service.EmployeeService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
public class EmployeeAction extends ActionSupport implements RequestAware,
ModelDriven<Employee>, Preparable{
/**
*
*/
private static final long serialVersionUID = 1L;
private EmployeeService employeeService;
public void setEmployeeService(EmployeeService employeeService) {
this.employeeService = employeeService;
}
private DepartmentService departmentService;
public void setDepartmentService(DepartmentService departmentService) {
this.departmentService = departmentService;
}
public String list() {
request.put("employees", employeeService.getAll());
return "list";
}
private Integer id;
public void setId(Integer id) {
this.id = id;
}
private InputStream inputStream;
public InputStream getInputStream() {
return inputStream;
}
public String delete() {
try {
employeeService.delete(id);
inputStream = new ByteArrayInputStream("1".getBytes("UTF-8"));
} catch (Exception e) {
e.printStackTrace();
try {
inputStream = new ByteArrayInputStream("0".getBytes("UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
}
return "ajax-success";
}
public String input(){
request.put("departments", departmentService.getAll());
return INPUT;
}
public void prepareInput(){
if(id != null){
model = employeeService.get(id);
}
}
public String save(){
if(id == null){
model.setCreateTime(new Date());
}
employeeService.saveOrUpdate(model);
return SUCCESS;
}
/**
* 鍙互鏍规嵁 id 鏉ュ垽鏂负 save 鏂规硶鍑嗗鐨� model 鏄� new 鐨勮繕鏄粠鏁版嵁搴撹幏鍙栫殑!
*/
public void prepareSave(){
if(id == null){
model = new Employee();
}else{
model = employeeService.get(id);
}
}
private String lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String validateLastName() throws UnsupportedEncodingException{
if(employeeService.lastNameIsValid(lastName)){
inputStream = new ByteArrayInputStream("1".getBytes("UTF-8"));
}else{
inputStream = new ByteArrayInputStream("0".getBytes("UTF-8"));
}
return "ajax-success";
}
private Map<String, Object> request;
@Override
public void setRequest(Map<String, Object> arg0) {
this.request = arg0;
}
@Override
public void prepare() throws Exception {}
private Employee model;
@Override
public Employee getModel() {
return model;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
eclipse实现spring+struts+hibernate整合
共90个文件
jar:37个
xml:14个
class:11个
需积分: 10 7 下载量 139 浏览量
2017-08-16
15:13:07
上传
评论
收藏 16.4MB ZIP 举报
温馨提示
eclipse中整合spring+struts+hibernate,能直接运行
资源推荐
资源详情
资源评论
收起资源包目录
ssh.zip (90个子文件)
ssh
.project 903B
WebContent
WEB-INF
views
emp-list.jsp 2KB
emp-input.jsp 2KB
lib
spring-context-4.0.0.RELEASE.jar 928KB
commons-lang3-3.1.jar 308KB
asm-commons-3.3.jar 37KB
jboss-transaction-api_1.1_spec-1.0.1.Final.jar 25KB
dom4j-1.6.1.jar 307KB
xwork-core-2.3.15.3.jar 626KB
spring-expression-4.0.0.RELEASE.jar 202KB
struts2-core-2.3.15.3.jar 784KB
spring-tx-4.0.0.RELEASE.jar 242KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
hibernate-core-4.2.4.Final.jar 4.41MB
spring-web-4.0.0.RELEASE.jar 646KB
spring-aop-4.0.0.RELEASE.jar 343KB
spring-beans-4.0.0.RELEASE.jar 654KB
javassist-3.15.0-GA.jar 633KB
log4j-1.2.17.jar 478KB
spring-core-4.0.0.RELEASE.jar 933KB
freemarker-2.3.19.jar 909KB
spring-jdbc-4.0.0.RELEASE.jar 410KB
commons-io-2.0.1.jar 156KB
asm-tree-3.3.jar 21KB
spring-aspects-4.0.0.RELEASE.jar 50KB
c3p0-0.9.1.2.jar 596KB
hibernate-jpa-2.0-api-1.0.1.Final.jar 100KB
antlr-2.7.7.jar 435KB
commons-fileupload-1.3.jar 67KB
commons-logging-1.1.3.jar 61KB
spring-orm-4.0.0.RELEASE.jar 309KB
asm-3.3.jar 43KB
struts2-spring-plugin-2.3.15.3.jar 21KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
jboss-logging-3.1.0.GA.jar 59KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
hibernate-commons-annotations-4.0.2.Final.jar 80KB
mysql-connector-java-5.1.7-bin.jar 693KB
ognl-3.0.6.jar 223KB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
web.xml 917B
index.jsp 762B
scripts
jquery-1.9.1.min.js 90KB
META-INF
MANIFEST.MF 39B
welcome.html 2KB
src
conf
applicationContext.xml 3KB
hibernate.cfg.xml 925B
applicationContext-beans.xml 1KB
db.properties 160B
struts.xml 2KB
com
atguigu
ssh
service
DepartmentService.java 419B
EmployeeService.java 815B
entities
Employee.hbm.xml 1KB
Department.java 538B
Department.hbm.xml 671B
Employee.java 1KB
converters
SSHDateConverter.java 839B
dao
DepartmentDao.java 281B
EmployeeDao.java 1KB
BaseDao.java 379B
actions
LoginAction.java 648B
EmployeeAction.java 3KB
test
SpringTest.java 823B
.tern-project 162B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 305B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 96B
org.eclipse.wst.common.component 461B
.jsdtscope 567B
build
classes
conf
applicationContext.xml 3KB
hibernate.cfg.xml 925B
applicationContext-beans.xml 1KB
db.properties 160B
struts.xml 2KB
com
atguigu
ssh
service
EmployeeService.class 2KB
DepartmentService.class 755B
entities
Employee.hbm.xml 1KB
Department.hbm.xml 671B
Employee.class 2KB
Department.class 1KB
converters
SSHDateConverter.class 1KB
dao
EmployeeDao.class 2KB
DepartmentDao.class 750B
BaseDao.class 657B
actions
EmployeeAction.class 4KB
LoginAction.class 933B
test
SpringTest.class 1KB
.classpath 790B
共 90 条
- 1
资源评论
nieshuangyan
- 粉丝: 46
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 请以C语言10进制转2进制示例.docx
- DMP3130L-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- halcon缺陷检测.docx
- 3DEC/UDEC4.0安装包,有好多;都是我在闲鱼买的 有需要的自己下载
- DMP3130L-7-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Unity插件 视频播放插件AVPro 1.7.3
- DMP3120L-VB一款SOT23封装P-Channel场效应MOS管
- BEG模型原始论文:C-Pack: Packaged Resources To Advance General Chinese
- 测试平台项目代码web
- "操作系统开发+Linux内核+源码注释+技术研究参考"
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功