Outsourcing human resource management system based on Spring MVC + Spring + MyBatis

Resource download: https://download.csdn.net/download/weixin_44893902/45600390

Exercise point design: fuzzy query, delete, add

1, Language and environment

  1. Implementation language: JAVA language.
  2. Environment requirements: MyEclipse/Eclipse + Tomcat + MySql.
  3. Use technology: Jsp+Servlet+JavaBean or spring MVC + Spring + mybatis.

2, Realize function

With the development of the company's business, an online outsourcing resource management system is needed. Its main functions are as follows:

  1. The home page displays all developer information by default, as shown in the figure.

2. When the mouse hovers over a row of data, the light bar effect is displayed with linear transition animation, as shown in the figure.

3. If the user selects a level, the query results will be displayed according to the level, as shown in the figure.

4. If you select the working years, you can query according to the working years and display the query results, as shown in the figure

5. The user selects two options, queries according to the two options, and displays the query results, as shown in the figure

6. The user's two options are blank. The default is full query, and the query results are displayed, as shown in the figure

7. Click Delete to pop up a prompt box. Click OK to delete the selected data and display the latest data, as shown in the figure.



8. The user fills in the form information at the bottom of the page, click "OK to add" to add the course information data to the database, and the page jumps to the list page to display the latest data, as shown in Figure 9. Before adding a course, you need to verify the name, as shown in Figure 10

3, Database design

1. Create a database (os_db).
2. Create a data table (os_db) with the following structure.

Field nameexplainField typelengthremarks
idnumberintPrimary key, self increment, increment is 1
nameBook namevarchar50Cannot be empty
authorauthorvarchar10Cannot be empty
publish_datePublication datedateCannot be empty
presspressvarchar50Cannot be empty

4, Recommended implementation steps

The implementation steps of SSM version are as follows:
(1) Create database and data table and add test data (add at least 5 test data).
(2) Create a Web project, create various packages, and import the jar files required by the project.
(3) Add relevant SSM framework support.
(4) Various configuration files required by the configuration project (mybatis configuration file, spring configuration file, spring MVC configuration file).
(5) Create an entity class.
(6) Mapper interface required to create MyBatis operation database and its Xml mapping database operation statement file.
(7) Create corresponding interfaces and implementation classes of business logic, implement corresponding businesses, and add references and injections to DAO/Mapper in the classes.
(8) Create the Controller class, add reference and injection to the business logic class in the Controller, and configure the spring MVC configuration file.
(9) Create relevant operation pages and beautify the pages with CSS.
(10) Realize various operation functions of the page and verify them in relevant places. The operation should be humanized.
(11) After debugging and running successfully, export relevant database files and submit them.

5, Implementation code

1. MySQL database

os_db.sql

/*
 Date: 06/08/2021 19:33:22
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_dever
-- ----------------------------
DROP TABLE IF EXISTS `tb_dever`;
CREATE TABLE `tb_dever`  (
  `dev_id` int(11) NOT NULL AUTO_INCREMENT,
  `dev_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `dev_level` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `dev_work_year` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `dev_in_year` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`dev_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tb_dever
-- ----------------------------
INSERT INTO `tb_dever` VALUES (1, 'Zhang San', 'senior', '40', '2021-08-02');
INSERT INTO `tb_dever` VALUES (2, 'Li Si', 'senior', '25', '2021-07-28');
INSERT INTO `tb_dever` VALUES (3, 'Wang Wu', 'intermediate', '40', '2020-11-13');
INSERT INTO `tb_dever` VALUES (4, 'Li Mei', 'senior', '35', '2021-05-12');
INSERT INTO `tb_dever` VALUES (5, 'Yang Qi', 'intermediate', '28', '2021-07-16');

SET FOREIGN_KEY_CHECKS = 1;

2. Project Java code

directory structure
os_db

JAR package:

src

com.generator

Generator.java

package com.generator;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

public class Generator {
	/*
	 * targetRuntime="MyBatis3Simple", Do not generate Example
	 */
	public void generateMyBatis() {
		// Warning messages during MBG execution
		List<String> warnings = new ArrayList<String>();
		// When the generated code is repeated, the original code is overwritten
		boolean overwrite = true;
		String generatorFile = "/generator/generatorConfig.xml";
		// String generatorFile = "/generator/generatorConfigExample.xml";
		// Read MBG configuration file
		InputStream is = Generator.class.getResourceAsStream(generatorFile);

		ConfigurationParser cp = new ConfigurationParser(warnings);
		Configuration config;
		try {
			config = cp.parseConfiguration(is);
			DefaultShellCallback callback = new DefaultShellCallback(overwrite);
			// Create MBG
			MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
			// Execute generated code
			myBatisGenerator.generate(null);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (XMLParserException e) {
			e.printStackTrace();
		} catch (InvalidConfigurationException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		for (String warning : warnings) {
			System.out.println(warning);
		}
	}

	public static void main(String[] args) {
		Generator generator = new Generator();
		generator.generateMyBatis();
	}
}

com.mhys.crm.controller

TbMemberInfoController.java

package com.mhys.crm.controller;

import java.util.List;

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

import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mhys.crm.entity.TbDever;
import com.mhys.crm.service.TbDeverService;

@Controller
public class TbMemberInfoController {
	@Resource
	private TbDeverService tbDeverservice;
	
	@RequestMapping("/list")
	public String getMemberList(Model model,String keyword,String devLevel) {
		
		List<TbDever> selctAll = tbDeverservice.getSelctAll(keyword,devLevel);
		model.addAttribute("selctAll", selctAll);
	    return "Dever";
	}
	@RequestMapping("/delDev")
	public String delDev(Model model,Integer id) {
		tbDeverservice.deleMember(id);
	    return "redirect:/list.do";
	}
	
	@RequestMapping("/toupdate")
	public String toadd(Model model,Integer id) {
		TbDever selByKey = tbDeverservice.selectByPrimaryKey(id);
		model.addAttribute("tbDever", selByKey);
	    return "updateDever";
	}
	
	@RequestMapping("/addDev")
	public String toaddDev(Model model,TbDever tbDever) {
		tbDeverservice.addMember(tbDever);
	    return "redirect:/list.do";
	}
	@RequestMapping("/upDev")
	public String upDev(Model model,TbDever upadtetbDever) {
		int update = tbDeverservice.updateByPrimaryKey(upadtetbDever);
		if (update>0) {
			System.out.println("QiChange succeeded");
			return "redirect:/list.do";
		}else {
			System.out.println("Qi"Change" button");
			return "forward:/toupdate.do";
		}
		
	}
}

com.mhys.crm.dao

TbDeverMapper.java

package com.mhys.crm.dao;

import com.mhys.crm.entity.TbDever;
import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface TbDeverMapper {
    int deleteByPrimaryKey(Integer devId);

    int insert(TbDever record);

    TbDever selectByPrimaryKey(Integer devId);

    List<TbDever> selectAll(@Param("keyword")String name,@Param("devLevel")String devLevel);

    int updateByPrimaryKey(TbDever record);
}

TbDeverMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mhys.crm.dao.TbDeverMapper" >
  <resultMap id="BaseResultMap" type="com.mhys.crm.entity.TbDever" >
    <id column="dev_id" property="devId" jdbcType="INTEGER" />
    <result column="dev_name" property="devName" jdbcType="VARCHAR" />
    <result column="dev_level" property="devLevel" jdbcType="VARCHAR" />
    <result column="dev_work_year" property="devWorkYear" jdbcType="VARCHAR" />
    <result column="dev_in_year" property="devInYear" jdbcType="VARCHAR" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tb_dever
    where dev_id = #{devId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mhys.crm.entity.TbDever" >
    insert into tb_dever (dev_id, dev_name, dev_level, 
      dev_work_year, dev_in_year)
    values (#{devId,jdbcType=INTEGER}, #{devName,jdbcType=VARCHAR}, #{devLevel,jdbcType=VARCHAR}, 
      #{devWorkYear,jdbcType=VARCHAR}, #{devInYear,jdbcType=VARCHAR})
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.mhys.crm.entity.TbDever" >
    update tb_dever
    set dev_name = #{devName,jdbcType=VARCHAR},
      dev_level = #{devLevel,jdbcType=VARCHAR},
      dev_work_year = #{devWorkYear,jdbcType=VARCHAR},
      dev_in_year = #{devInYear,jdbcType=VARCHAR}
    where dev_id = #{devId,jdbcType=INTEGER}
  </update>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select dev_id, dev_name, dev_level, dev_work_year, dev_in_year
    from tb_dever
    where dev_id = #{devId,jdbcType=INTEGER}
  </select>
  <select id="selectAll" resultMap="BaseResultMap" >
    select dev_id, dev_name, dev_level, dev_work_year, dev_in_year
    from tb_dever
    <where>
    <if test="devLevel!=null and devLevel!=''">
    	and dev_level = #{devLevel}
    </if>
    <if test="keyword!=null and keyword!=''">
    	and dev_work_year > #{keyword}
    </if>
    </where>
    
  </select>
</mapper>

com.mhys.crm.entity

TbDever.java

package com.mhys.crm.entity;

public class TbDever {
    private Integer devId;

    private String devName;

    private String devLevel;

    private String devWorkYear;

    private String devInYear;

    public Integer getDevId() {
        return devId;
    }

    public void setDevId(Integer devId) {
        this.devId = devId;
    }

    public String getDevName() {
        return devName;
    }

    public void setDevName(String devName) {
        this.devName = devName == null ? null : devName.trim();
    }

    public String getDevLevel() {
        return devLevel;
    }

    public void setDevLevel(String devLevel) {
        this.devLevel = devLevel == null ? null : devLevel.trim();
    }

    public String getDevWorkYear() {
        return devWorkYear;
    }

    public void setDevWorkYear(String devWorkYear) {
        this.devWorkYear = devWorkYear == null ? null : devWorkYear.trim();
    }

    public String getDevInYear() {
        return devInYear;
    }

    public void setDevInYear(String devInYear) {
        this.devInYear = devInYear == null ? null : devInYear.trim();
    }
}

com.mhys.crm.service

TbDeverService.java

package com.mhys.crm.service;

import java.util.List;

import com.mhys.crm.entity.TbDever;

public interface TbDeverService {
	//Query all and fuzzy queries
	List<TbDever> getSelctAll(String name,String devLevel);
	//add to
	int addMember(TbDever record);
	//delete
	int deleMember(int id);
	//modify
	int updateByPrimaryKey(TbDever record);
	//Query by ID
	TbDever selectByPrimaryKey(Integer devId);

}


com.mhys.crm.service.impl

TbDeverServiceImpl.java

package com.mhys.crm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mhys.crm.dao.TbDeverMapper;
import com.mhys.crm.entity.TbDever;
import com.mhys.crm.service.TbDeverService;
@Service
public class TbDeverServiceImpl implements TbDeverService{
	@Resource
	private TbDeverMapper infoMapper;
	
	@Override
	public List<TbDever> getSelctAll(String name,String devLevel) {
		// TODO Auto-generated method stub
		List<TbDever> infoList=infoMapper.selectAll(name,devLevel);
		return infoList;
	}

	@Override
	public int addMember(TbDever record) {
		// TODO Auto-generated method stub
		int add=infoMapper.insert(record);
		return add;
	}

	@Override
	public int deleMember(int id) {
		// TODO Auto-generated method stub
		int del=infoMapper.deleteByPrimaryKey(id);
		return del;
	}

	@Override
	public int updateByPrimaryKey(TbDever record) {
		// TODO Auto-generated method stub
		int up = infoMapper.updateByPrimaryKey(record);
		return up;
	}

	@Override
	public TbDever selectByPrimaryKey(Integer devId) {
		// TODO Auto-generated method stub
		TbDever si = infoMapper.selectByPrimaryKey(devId);
		return si;
	}

}

MyBatis

SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<typeAliases>
		<package name="com.mhys.crm.entity"/>
	</typeAliases>
</configuration>

spring

applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
	
	<!-- appoint spring Container read db.properties file -->
	<context:property-placeholder location="classpath:database.properties"></context:property-placeholder>
	<!-- Register connection pool with bean In container -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}"></property>
		<property name="Url" value="${jdbc.url}"></property>
		<property name="username" value="${jdbc.username}"></property>
		<property name="password" value="${jdbc.password}"></property>
	</bean>
	<!-- to configure SqlSessionFactory -->
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- set up MyBatis Core profile -->
		<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
		<!-- set up data sources -->
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- to configure Mapper scanning -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- set up Mapper Scan package -->
		<property name="basePackage"  value="com.mhys.crm.dao" />
	</bean>
	<!-- Configure transaction manager -->
		<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
			<property name="dataSource" ref="dataSource"></property>
		</bean>
		<!-- Enable annotation mode management AOP affair -->
		<tx:annotation-driven transaction-manager="transactionManager" />
	
</beans>

applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">

	<context:component-scan base-package="com.mhys.crm" />
	<!-- 
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<tx:annotation-driven transaction-manager="transactionManager" /> -->
	
</beans>

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:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

	<context:component-scan base-package="com.mhys.crm" />
	
	<mvc:annotation-driven />
	
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
	
	
</beans>
	

dataSource.properties

jdbc.url=jdbc:mysql://localhost:3306/os_db?characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456
jdbc.driver=com.mysql.jdbc.Driver

generatorConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
  PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- Configuration Generator  -->
<generatorConfiguration>
	<context id="MySQLContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
		<!-- Configure leading and trailing delimiters -->
		<property name="beginningDelimiter" value="`"/>
		<property name="endingDelimiter" value="`"/>
		<!-- Configure comment information -->
		<commentGenerator>
			<!-- Do not generate comments -->
			<property name="suppressAllComments" value="true"/>
			<property name="suppressDate" value="true"/>
			<property name="addRemarkComments" value="true"/>
		</commentGenerator>
		<!-- Database connection configuration -->
		<jdbcConnection driverClass="com.mysql.jdbc.Driver" 
				connectionURL="jdbc:mysql://localhost:3306/os_db"
				userId="root" password="123456">
		</jdbcConnection>
		
		<!-- targetPackage: Generate the package name stored in the entity class, targetProject: Specify the target project path, either relative or absolute -->
		<javaModelGenerator targetPackage="com.mhys.crm.entity" targetProject="src">
			<property name="trimStrings" value="true"/>
		</javaModelGenerator>
		
		<!-- to configure SQL Mapper Mapper.xml File properties -->
		<sqlMapGenerator targetPackage="com.mhys.crm.dao" targetProject="src"/>
		
		<!-- type="XMLMAPPER": All the methods are in use XML Interface call dependency XML file -->
		<javaClientGenerator targetPackage="com.mhys.crm.dao" type="XMLMAPPER" 
								targetProject="src"/>
								
		<!-- Generate mappings for all tables -->
		<table tableName="%"></table>		
	</context>
</generatorConfiguration>

WebContent

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>os_db</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
   <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/applicationContext-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:spring/spring-mvc.xml</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>CharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>

JSP

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>XXX system</title>
</head>
<body>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<script>
	window.location.href="<%=basePath%>/list.do";
</script>
</body>
</html>

modifyTb.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>modify</title>
<style type="text/css">
	.cc{
		color: red;
	}
</style>
</head>
<body>
	<div>
		<form:form action="modifyInfo.do" modelAttribute="tbSupply" method="post">
			<h1>Office supplies warehousing</h1>
			<form:hidden path="id"/>
			Item No.:<input name="id" value=${param.id } disabled='disabled' /><form:errors class="cc" path="id"></form:errors><br/>
			Item name:<input name="name" value=${param.name } disabled='disabled'/><form:errors class="cc" path="name"></form:errors><br/>
			Item specification:<input name="model" value=${param.model } placeholder="No specification" disabled='disabled'/><form:errors class="cc" path="model"></form:errors><br/>
			Receipt quantity:<form:input path="quantity"/><form:errors class="cc" path="quantity"></form:errors><br/>
			<input type="submit" value="Warehousing"/>
		</form:form>
	</div>
</body>
</html>

Dever.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<style>
	table{
		width: 100%;
		margin: 0 auto;
	}
	#add{
	  text-decoration: none;
	  float:right;
	  border: 1px;
	  padding:3px;
	  background-color: blue;
	  color: white;
	  width: 150px;
	}
	tr:hover{
		background: orange;
	}
	
	
</style>
</head>
<body>
	<h2 style="text-align: center;">Outsourcing human resource management system</h2>
 	 <div style="border:2px solid balck;margin-bottom: 10px;">
 	 	 <b>search</b>
			<div style="margin-bottom: 30px;border:1px solid black;padding: 10px;">
			<form action="list.do" >
			    Level:<select name="devLevel"><option value="">Please select</option>
			    <option value="primary">primary</option>
			    <option value="intermediate">intermediate</option>
			    <option value="senior">senior</option></select>
				Working years greater than:<input type="text" name="keyword" id="keyword" value="" />
				<input type="submit" style="background-color: blue;color: white; width: 100px;" value="View results"/>
				<!-- <input οnclick='location.href=("toadd.do")' type="button" id="add" value="Add employee"/> -->
			</form>
			</div>
 	 </div>
 	 <b>resource list</b>
 	 <table style="margin-bottom: 30px;" width="100%" border="1px" cellpadding="9" cellspacing="0">
		<tr class="text">
			<td width="10%" align="center">number</td>
			<td width="10%" align="center">full name</td>
			<td width="10%" align="center">Grade</td>
			<td width="10%" align="center">Working years</td>
			<td width="10%" align="center">Entry time</td>			
			<td align="center" width="10%">operation</td>
		</tr>
			<c:forEach items="${selctAll}" var="dever">
				<tr align="center">
				 	<td>
				 		${dever.devId}
				 	</td>
				 	<td>
						${dever.devName}
					</td>
					<td>
						${dever.devLevel}
					</td>
					<td>
						${dever.devWorkYear}
					</td>
					<td>
						${dever.devInYear}
					</td>
					<td>
						<a href="delDev.do?id=${dever.devId}" onclick=" return confirm('Are you sure you want to delete?')" >delete</a>
						<a href="toupdate.do?id=${dever.devId}" >modify</a>
					</td>                    
				</tr>
			</c:forEach>
	</table>
	<b>Add people</b>
	<div class="addMoot">
				
		<form:form modelAttribute="tbDever" id="addform" action="addDev.do" method="post">
				<table style="text-align: center;" border="1" cellspacing="0" cellpadding="0">			
					<tr style="height:40px;">
						<td>full name:</td>
						<td>
							<input type="text" name="devName" class="cc" placeholder="Please enter your name" id="" value="" />
						</td>
					</tr>		
										
					<tr style="height:40px;">
						<td>Grade:</td>
						<td>
							<select id="STATUS" name="devLevel" >
								<option value = "senior" >senior</option>
								<option value = "intermediate" >intermediate</option>
								<option value = "primary" >primary</option>
							</select>
						</td>
					</tr>
					<tr style="height:40px;">
						<td>Working years:</td>
						<td>
							<input type="text" name="devWorkYear" class="cc" placeholder="Please enter years of service" id="" value="" />
						</td>
					</tr>

					<tr style="height:40px;">
						<td>Entry time:</td>
						<td>
							<input type="date" name="devInYear" class="cc" placeholder="Please enter the employment time" id="" value="" />
						</td>
					</tr>
										
					<tr style="height:40px;">
						<td class="btn" colspan="2">
							<input class="submit_btn" type="submit" value="Confirm add"/>&nbsp;&nbsp;&nbsp;
							<input class="cancel_btn" type="button" onclick="history.back(-1)" value="cancel"/>
						</td>
					</tr>
				</table>
			</form:form>
		</div>
</body>
<script src="<%=request.getContextPath()%>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
</script>

</html>

updateDever.jsp

<?xml version="1.0" encoding="UTF-8" ?>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Modify information</title>
<style type="text/css">
		.addMoot{
			width: 560px;
			margin: 100px auto;
			background:url(images/main_bg.png) repeat;
			margin-left:auto; 
			margin-right:auto;
			text-align:left; 
			float:none; 
			border-radius:8px;
			color: white;
			font-size:16px;
			font-weight: 100;
			padding: 10px
		}
		table{
			text-align: center;
			width: 100%;
			border: none;
		}
		.cc{
			width: 95%;
			height: 100%;
			border: none;
			height: 25px;
		}
		textarea{
			width: 95%;
			height: 70%;
			border-color: white;
		}
		input{
			height: 35px;
			border-color: white;
		}
		td{
			height: 35px;
		}
		.fee{
			height: 35px;
			display: flex;
			align-items: center;
			justify-content: flex-start;
		}
		.btn>input{
			padding: 8px 40px;
			letter-spacing: 3px;
			background-color: #3872f6;
			border: none;
			border-radius: 3px;
			color: #FFFFFF;
			margin: 10px;
		}
		td{
			border: 0.5px solid #3872f6;
			border-bottom: none;
			border-right: none;
		}
		.addMoot{
			text-align: center;
			background-color: darkgray;
		}
		.add_title{
			font-size: 24px;
			font-weight: 400;
			letter-spacing: 2px;
			margin-top: 20px
		}
		.btn{
			border: none;
		}
		td{
			border: none;
		}
		.STATUS{
			width: 85%;
		}
	</style>
</head>
<body>
<%-- <%
SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
String dat=sf.format(new Date());
%> --%>
		<div class="addMoot">
				<p class="add_title">
				modify 
				</p>
		<form:form modelAttribute="upadtetbDever" id="addform" action="upDev.do" method="post">
				<table border="0" cellspacing="0" cellpadding="0">			
					<tr>
						<td>full name:</td>
						<td>
							<input type="text" name="devName" class="cc" id="" value="${tbDever.devName }" />
							<input type="hidden" name="devId" value="${tbDever.devId }" />
						</td>
					</tr>		
										
					<tr>
						<td>Grade:</td>
						<td>
							<select id="STATUS" name="devLevel" >
								<option <c:if test="${tbDever.devLevel=='senior' }">selected="selected"</c:if>  value = "senior" >senior</option>
								<option <c:if test="${tbDever.devLevel=='intermediate' }">selected="selected"</c:if>   value = "intermediate" >intermediate</option>
								<option <c:if test="${tbDever.devLevel=='primary' }">selected="selected"</c:if>  value = "primary" >primary</option>
							</select>
						</td>
					</tr>
					<tr>
						<td>Working years:</td>
						<td>
							<input type="text" name="devWorkYear" class="cc"  id="" value="${tbDever.devWorkYear }" />
						</td>
					</tr>

					<tr>
						<td>Entry time:</td>
						<td>
							<input type="date" name="devInYear" class="cc"  id="" value="${tbDever.devInYear }" />
						</td>
					</tr>
										
					<tr>
						<td class="btn" colspan="2">
							<input class="submit_btn" type="submit" value="Confirm modification"/>&nbsp;&nbsp;&nbsp;
							<input class="cancel_btn" type="button" onclick="history.back(-1)" value="cancel"/>
						</td>
					</tr>
				</table>
			</form:form>
		</div>
</body>
</html>

Tags: Java MySQL MyEclipse Spring mvc

Posted on Sun, 21 Nov 2021 21:09:55 -0500 by beginPHP