HiddenHttpMethodFilter
/*
spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=“http://www.springframework.org/schema/context”
xmlns:mvc=“http://www.springframework.org/schema/mvc”
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package=“com.*” />
<bean id=“viewResolver”
class=“org.springframework.web.servlet.view.InternalResourceViewResolver”>
mvc:annotation-driven</mvc:annotation-driven>
<mvc:default-servlet-handler />
index.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
dataList.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
<c:if test=“${empty requestScope.list }”>
没有查询到数据</c:if>
<c:if test=“${!empty requestScope.list }”>
ID 姓名 SSN 部门名称 操作<c:forEach items=“${requestScope.list }” var=“list”>
${list.empId} ${list.empName} ${list.ssn } ${list.department.deptName } 删除 编辑</c:forEach>
</c:if>
dataEdit.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
method=“post”>
<c:if test=“${!empty deptList }”>
<c:forEach items=“${requestScope.deptList}” var=“dept”>
<c:if test=“${dept.deptId==requestScope.emdit.department.deptId }”>
${dept.deptName }</c:if>
${dept.deptName }</c:forEach>
</c:if>
dataAdd.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c”%>
<c:if test=“${empty deptList }”>
部门数据查询失败!!!</c:if>
<c:if test=“${!empty deptList }”>
<c:forEach items=“${requestScope.deptList}” var=“dept”>
${dept.deptName }</c:forEach>
</c:if>
DeptDao.java
package com.dao;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.stereotype.Repository;
import com.pojo.Department;
@Repository
public class DeptDao {
private static Map<String, Department> dataMap;
private static Map<String, Department> namedMap;
static {
dataMap = new HashMap<>();
namedMap = new HashMap<>();
Department department = new Department(UUID.randomUUID().toString(), “市场部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
department = new Department(UUID.randomUUID().toString(), “销售部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
department = new Department(UUID.randomUUID().toString(), “行政部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
department = new Department(UUID.randomUUID().toString(), “人事部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
department = new Department(UUID.randomUUID().toString(), “技术部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
department = new Department(UUID.randomUUID().toString(), “公关部”);
dataMap.put(department.getDeptId(), department);
namedMap.put(department.getDeptName(), department);
}
public static Department getDeptByName(String deptName) {
return namedMap.get(deptName);
}
public static Department getDeptById(String uuid) {
return dataMap.get(uuid);
}
public List getDeptList() {
return new ArrayList<>(dataMap.values());
}
}
EmpDao.java
package com.dao;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.stereotype.Repository;
import com.pojo.Department;
import com.pojo.Employee;
@Repository
public class EmpDao {
private static Map<String, Employee> dataMap;
static {
dataMap = new HashMap<>();
String empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “乔峰”, “SSN001”, DeptDao.getDeptByName(“市场部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “虚竹”, “SSN002”, DeptDao.getDeptByName(“市场部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “段誉”, “SSN003”, DeptDao.getDeptByName(“市场部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “鸠摩智”, “SSN004”, DeptDao.getDeptByName(“技术部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “萧远山”, “SSN005”, DeptDao.getDeptByName(“技术部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “慕容复”, “SSN006”, DeptDao.getDeptByName(“技术部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “段正淳”, “SSN007”, DeptDao.getDeptByName(“公关部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “段延庆”, “SSN008”, DeptDao.getDeptByName(“公关部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “丁春秋”, “SSN009”, DeptDao.getDeptByName(“销售部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “无崖子”, “SSN010”, DeptDao.getDeptByName(“人事部”)));
empId = UUID.randomUUID().toString();
dataMap.put(empId, new Employee(empId, “慕容博”, “SSN011”, DeptDao.getDeptByName(“人事部”)));
}
public void saveEmp(Employee employee) {
String empId = UUID.randomUUID().toString();
employee.setEmpId(empId);
String deptId = employee.getDepartment().getDeptId();
Department department = DeptDao.getDeptById(deptId);
employee.setDepartment(department);
dataMap.put(empId, employee);
}
public void removeEmp(String empId) {
dataMap.remove(empId);
}
public void updateEmp(Employee employee) {
String deptId = employee.getDepartment().getDeptId();
Department department = DeptDao.getDeptById(deptId);
employee.setDepartment(department);
dataMap.put(employee.getEmpId(), employee);
}
public Employee getEmpById(String empId) {
return dataMap.get(empId);
}
public List getEmpList() {
return new ArrayList<>(dataMap.values());
}
}
Department
package com.pojo;
public class Department {
private String deptId;
private String deptName;
public Department() {
}
public Department(String deptId, String deptName) {
super();
this.deptId = deptId;
this.deptName = deptName;
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@Override
public String toString() {
return “Department [deptId=” + deptId + “, deptName=” + deptName + “]”;
}
}
Employee
package com.pojo;
public class Employee {
private String empId;
private String empName;
private String ssn;
private Department department;
public Employee(String empId, String empName, String ssn, Department department) {
super();
this.empId = empId;
this.empName = empName;
this.ssn = ssn;
this.department = department;
}
public Employee() {
}
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getSsn() {
return ssn;
}
public void setSsn(String ssn) {
this.ssn = ssn;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
@Override
public String toString() {
return “Employee [empId=” + empId + “, empName=” + empName + “, ssn=” + ssn + “, department=” + department
- “]”;
}
}
Services
package com.services;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dao.DeptDao;
import com.dao.EmpDao;
import com.pojo.Department;
import com.pojo.Employee;
@Service
public class Services {
@Autowired
private DeptDao deptDao;
@Autowired
private EmpDao empDao;
public List deptDaoList(){
return deptDao.getDeptList();
};
public List empDaoList(){
return empDao.getEmpList();
}
public void saveData(Employee employee) {
empDao.saveEmp(employee);
}
public void delectData(String empId) {
empDao.removeEmp(empId);
}
public Employee emdit(String empId) {
Employee empById = empDao.getEmpById(empId);
return empById;
}
public void updateEmp(Employee employee) {
empDao.updateEmp(employee);
}
}
Handled
package com.handled;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
最后
现在其实从大厂招聘需求可见,在招聘要求上有高并发经验优先,包括很多朋友之前都是做传统行业或者外包项目,一直在小公司,技术搞的比较简单,没有怎么搞过分布式系统,但是现在互联网公司一般都是做分布式系统。
所以说,如果你想进大厂,想脱离传统行业,这些技术知识都是你必备的,下面自己手打了一份Java并发体系思维导图,希望对你有所帮助。
ivate EmpDao empDao;
public List deptDaoList(){
return deptDao.getDeptList();
};
public List empDaoList(){
return empDao.getEmpList();
}
public void saveData(Employee employee) {
empDao.saveEmp(employee);
}
public void delectData(String empId) {
empDao.removeEmp(empId);
}
public Employee emdit(String empId) {
Employee empById = empDao.getEmpById(empId);
return empById;
}
public void updateEmp(Employee employee) {
empDao.updateEmp(employee);
}
}
Handled
package com.handled;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
最后
现在其实从大厂招聘需求可见,在招聘要求上有高并发经验优先,包括很多朋友之前都是做传统行业或者外包项目,一直在小公司,技术搞的比较简单,没有怎么搞过分布式系统,但是现在互联网公司一般都是做分布式系统。
所以说,如果你想进大厂,想脱离传统行业,这些技术知识都是你必备的,下面自己手打了一份Java并发体系思维导图,希望对你有所帮助。
[外链图片转存中…(img-Lr32USyX-1718903999369)]