• 大小: 17.87MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-20
  • 语言: 其他
  • 标签: SSH  CRUD  

资源简介

SSH 整合实现增删改查

资源截图

代码片段和文件信息

package com.cqvie.action;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.RequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.cqvie.model.Department;
import com.cqvie.model.Employee;
import com.cqvie.service.DepartmentService;
import com.cqvie.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

@Component(“employeeAction“)
@Scope(“prototype“)
public class EmployeeAction extends ActionSupport implements ModelDriven RequestAware Preparable {

private static final long serialVersionUID = 1L;

private Mapject> request;
private Employee emp = new Employee();
private EmployeeService employeeService;
private DepartmentService departmentService;
private InputStream inputStream;

public Employee getEmp() {
return emp;
}
public void setEmp(Employee emp) {
this.emp = emp;
}
public EmployeeService getEmployeeService() {
return employeeService;
}
@Resource
public void setEmployeeService(EmployeeService employeeService) {
this.employeeService = employeeService;
}
public DepartmentService getDepartmentService() {
return departmentService;
}
@Resource
public void setDepartmentService(DepartmentService departmentService) {
this.departmentService = departmentService;
}
public Mapject> getRequest() {
return request;
}
public void setRequest(Mapject> request) {
this.request = request;
}
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}

@Override
public Employee getModel() {
return emp;
}

/**
 * 修改用户时获得该 UUID
 */
ActionContext context = ActionContext.getContext();
HttpServletRequest req = (HttpServletRequest) context.get(ServletActionContext.HTTP_REQUEST);
    String e_uuid = req.getParameter(“e_uuid“);

/**
 * 获得所有员工的信息
 * @return
 */
public String list() {
List employees = employeeService.getAllEmployee();
request.put(“employees“ employees);
return “list“;
}

/**
 * 跳转到修改、增加界面
 */
public String input() {
List departments = departmentService.getAllDepartment();
request.put(“departments“ departments);
return “input“;
}
/**
 * 修改界面的显示当前信息
 */
public void prepareInput() {
System.err.println(“*******“ + e_uuid + “********“);
if(e_uuid != null) {
emp = employeeService.getEmployee(e_uuid)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-04-11 08:25  SSH_170331\
     文件         884  2017-03-31 11:43  SSH_170331\.classpath
     文件        1043  2017-03-31 15:53  SSH_170331\.project
     目录           0  2017-04-11 08:25  SSH_170331\.settings\
     文件         567  2017-03-31 11:41  SSH_170331\.settings\.jsdtscope
     文件         364  2017-03-31 11:41  SSH_170331\.settings\org.eclipse.jdt.core.prefs
     文件         557  2017-03-31 15:53  SSH_170331\.settings\org.eclipse.wst.common.component
     文件         345  2017-03-31 11:41  SSH_170331\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-03-31 11:41  SSH_170331\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-03-31 11:41  SSH_170331\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-04-11 08:25  SSH_170331\build\
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\
     文件        3486  2017-03-31 11:53  SSH_170331\build\classes\applicationContext.xml
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\action\
     文件        6190  2017-04-06 10:04  SSH_170331\build\classes\com\cqvie\action\EmployeeAction.class
     文件        1453  2017-04-06 10:17  SSH_170331\build\classes\com\cqvie\action\EmployeeActionTest.class
     文件        3256  2017-04-06 10:05  SSH_170331\build\classes\com\cqvie\action\LoginAction.class
     文件        2018  2017-04-01 09:48  SSH_170331\build\classes\com\cqvie\action\LoginActionTest.class
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\converters\
     文件        1323  2017-04-01 18:53  SSH_170331\build\classes\com\cqvie\converters\SSHDateConverter.class
     文件          52  2017-04-01 18:52  SSH_170331\build\classes\com\cqvie\converters\xwork-conversion.properties
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\dao\
     文件         376  2017-04-06 10:08  SSH_170331\build\classes\com\cqvie\dao\DepartmentDao.class
     文件         504  2017-04-06 10:09  SSH_170331\build\classes\com\cqvie\dao\EmployeeDao.class
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\dao\impl\
     文件        2116  2017-04-01 18:06  SSH_170331\build\classes\com\cqvie\dao\impl\DepartmentDaoImpl.class
     文件        3061  2017-04-06 10:11  SSH_170331\build\classes\com\cqvie\dao\impl\EmployeeDaoImpl.class
     目录           0  2017-04-11 08:25  SSH_170331\build\classes\com\cqvie\model\
     文件         981  2017-04-01 09:13  SSH_170331\build\classes\com\cqvie\model\Department.class
............此处省略104个文件信息

评论

共有 条评论