资源简介
尚硅谷资源
代码片段和文件信息
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 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 Mapject> request;
@Override
public void setRequest(Mapject> arg0) {
this.request = arg0;
}
@Override
public void prepare() throws Exception {}
private Employee model;
@Override
public Employee getModel() {
return model;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 884 2014-07-22 11:14 ssh-2\.classpath
文件 1246 2014-07-22 11:14 ssh-2\.project
文件 503 2014-07-22 11:11 ssh-2\.settings\.jsdtscope
文件 364 2014-07-22 11:11 ssh-2\.settings\org.eclipse.jdt.core.prefs
文件 544 2014-07-22 11:14 ssh-2\.settings\org.eclipse.wst.common.component
文件 345 2014-07-22 11:11 ssh-2\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-07-22 11:11 ssh-2\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-07-22 11:11 ssh-2\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 486 2014-07-22 11:49 ssh-2\.springBeans
文件 1164 2014-07-22 15:18 ssh-2\build\classes\applicationContext-beans.xm
文件 2664 2014-07-23 09:13 ssh-2\build\classes\applicationContext.xm
文件 4287 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\actions\EmployeeAction.class
文件 1336 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\converters\SSHDateConverter.class
文件 657 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\dao\ba
文件 750 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\dao\DepartmentDao.class
文件 2374 2014-07-23 12:17 ssh-2\build\classes\com\atguigu\ssh\dao\EmployeeDao.class
文件 1169 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\entities\Department.class
文件 671 2014-07-22 11:22 ssh-2\build\classes\com\atguigu\ssh\entities\Department.hbm.xm
文件 2212 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\entities\Employee.class
文件 1256 2014-07-23 12:13 ssh-2\build\classes\com\atguigu\ssh\entities\Employee.hbm.xm
文件 755 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\service\DepartmentService.class
文件 1649 2014-07-23 12:15 ssh-2\build\classes\com\atguigu\ssh\service\EmployeeService.class
文件 160 2014-07-22 11:26 ssh-2\build\classes\db.properties
文件 796 2014-07-22 11:19 ssh-2\build\classes\hibernate.cfg.xm
文件 1345 2014-07-23 09:15 ssh-2\build\classes\struts.xm
文件 58 2014-07-22 15:28 ssh-2\build\classes\xwork-conversion.properties
文件 1164 2014-07-22 15:18 ssh-2\conf\applicationContext-beans.xm
文件 2664 2014-07-23 09:13 ssh-2\conf\applicationContext.xm
文件 160 2014-07-22 11:26 ssh-2\conf\db.properties
文件 796 2014-07-22 11:19 ssh-2\conf\hibernate.cfg.xm
............此处省略88个文件信息
评论
共有 条评论