一、语言和环境
- 实现语言:JAVA语言。
- 环境要求:MyEclipse/Eclipse + Tomcat + MySql。
- 使用技术:
Jsp
+Servle
t+JavaBean
或SpringMVC
+Spring
+Mybatis
。
二、实现功能
随着公司业务的发展,需要一款在线外包资源管理系统,主要功能如下:
- 首页默认显示所有开发人员信息,如图所示。
2.鼠标悬停某行数据时,以线性过渡动画显示光棒效果,如图所示。
3.用户选择级别,则根据级别查询,显示查询结果,如图所示。
4.用户选择工作年限,则根据工作年限查询,显示查询结果,如图所示
5.用户选择两个选项,根据两个选项查询,显示查询结果,如图所示
6.用户两个选项为空,默认为全查,显示查询结果,如图所示
7.用户点击删除,弹出提示框,用户点击确定后,删除选中数据并显示最新数据,如图所示。
8.用户在页面下方填写表单信息,点击“确定添加”按钮,增加课程信息数据到数据库, 且页面跳转到列表页面展示最新数据,如图9所示。添加课程之前,需要对姓名进行非空验证,如图10所示
三、数据库设计
1.创建数据库(os_db
)。
2.创建数据表(os_db
),结构如下。
四、推荐实现步骤
SSM版本的实现步骤如下:
(1)创建数据库和数据表,添加测试数据(至少添加5条测试数据)。
(2)创建Web工程并创建各个包,导入工程所需的jar文件。
(3)添加相关SSM框架支持。
(4)配置项目所需要的各种配置文件(mybatis配置文件、spring配置文件、springMVC配置文件)。
(5)创建实体类。
(6)创建MyBatis操作数据库所需的Mapper接口及其Xml映射数据库操作语句文件。
(7)创建业务逻辑相应的接口及其实现类,实现相应的业务,并在类中加入对DAO/Mapper的引用和注入。
(8)创建Controller控制器类,在Controller中添加对业务逻辑类的引用和注入,并配置springMVC配置文件。
(9)创建相关的操作页面,并使用CSS对页面进行美化。
(10)实现页面的各项操作功能,并在相关地方进行验证,操作要人性化。
(11)调试运行成功后导出相关的数据库文件并提交。
五、实现代码
1、MySQL数据库
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, '张三', '高级', '40', '2021-08-02'); INSERT INTO `tb_dever` VALUES (2, '李四', '高级', '25', '2021-07-28'); INSERT INTO `tb_dever` VALUES (3, '王五', '中级', '40', '2020-11-13'); INSERT INTO `tb_dever` VALUES (4, '李梅', '高级', '35', '2021-05-12'); INSERT INTO `tb_dever` VALUES (5, '杨齐', '中级', '28', '2021-07-16'); SET FOREIGN_KEY_CHECKS = 1;
2、项目Java代码
目录结构
os_db
JAR包:
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", 不生成Example */ public void generateMyBatis() { // MBG执行过程中的警告信息 List<String> warnings = new ArrayList<String>(); // 当生成的代码重复时,覆盖原代码 boolean overwrite = true; String generatorFile = "/generator/generatorConfig.xml"; // String generatorFile = "/generator/generatorConfigExample.xml"; // 读取MBG配置文件 InputStream is = Generator.class.getResourceAsStream(generatorFile); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config; try { config = cp.parseConfiguration(is); DefaultShellCallback callback = new DefaultShellCallback(overwrite); // 创建MBG MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings); // 执行生成代码 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("淇敼鎴愬姛"); return "redirect:/list.do"; }else { System.out.println("淇敼澶辫触"); 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 { //查询所有和模糊查询 List<TbDever> getSelctAll(String name,String devLevel); //添加 int addMember(TbDever record); //删除 int deleMember(int id); //修改 int updateByPrimaryKey(TbDever record); //按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"> <!-- 指定spring容器读取db.properties文件 --> <context:property-placeholder location="classpath:database.properties"></context:property-placeholder> <!-- 将连接池注册到bean容器中 --> <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> <!-- 配置SqlSessionFactory --> <bean class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 设置MyBatis核心配置文件 --> <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" /> <!-- 设置数据源 --> <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置Mapper扫描 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!-- 设置Mapper扫描包 --> <property name="basePackage" value="com.mhys.crm.dao" /> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 开启注解方式管理AOP事务 --> <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"> <!-- 配置生成器 --> <generatorConfiguration> <context id="MySQLContext" targetRuntime="MyBatis3Simple" defaultModelType="flat"> <!-- 配置前置分隔符和后置分隔符 --> <property name="beginningDelimiter" value="`"/> <property name="endingDelimiter" value="`"/> <!-- 配置注释信息 --> <commentGenerator> <!-- 不生成注释 --> <property name="suppressAllComments" value="true"/> <property name="suppressDate" value="true"/> <property name="addRemarkComments" value="true"/> </commentGenerator> <!-- 数据库连接配置 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/os_db" userId="root" password="123456"> </jdbcConnection> <!-- targetPackage:生成实体类存放的包名, targetProject:指定目标项目路径,可以使用相对路径或绝对路径 --> <javaModelGenerator targetPackage="com.mhys.crm.entity" targetProject="src"> <property name="trimStrings" value="true"/> </javaModelGenerator> <!-- 配置SQL映射器Mapper.xml文件的属性 --> <sqlMapGenerator targetPackage="com.mhys.crm.dao" targetProject="src"/> <!-- type="XMLMAPPER":所有的方法都在XML中,接口调用依赖XML文件 --> <javaClientGenerator targetPackage="com.mhys.crm.dao" type="XMLMAPPER" targetProject="src"/> <!-- 生成所有表的映射 --> <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系统</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>修改</title> <style type="text/css"> .cc{ color: red; } </style> </head> <body> <div> <form:form action="modifyInfo.do" modelAttribute="tbSupply" method="post"> <h1>办公用品入库</h1> <form:hidden path="id"/> 物品编号:<input name="id" value=${param.id } disabled='disabled' /><form:errors class="cc" path="id"></form:errors><br/> 物品名称:<input name="name" value=${param.name } disabled='disabled'/><form:errors class="cc" path="name"></form:errors><br/> 物品规格:<input name="model" value=${param.model } placeholder="暂无规格" disabled='disabled'/><form:errors class="cc" path="model"></form:errors><br/> 入库数量:<form:input path="quantity"/><form:errors class="cc" path="quantity"></form:errors><br/> <input type="submit" value="入库"/> </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;">外包人力资源管理系统</h2> <div style="border:2px solid balck;margin-bottom: 10px;"> <b>搜索</b> <div style="margin-bottom: 30px;border:1px solid black;padding: 10px;"> <form action="list.do" > 级别:<select name="devLevel"><option value="">请选择</option> <option value="初级">初级</option> <option value="中级">中级</option> <option value="高级">高级</option></select> 工作年限大于:<input type="text" name="keyword" id="keyword" value="" /> <input type="submit" style="background-color: blue;color: white; width: 100px;" value="查看结果"/> <!-- <input οnclick='location.href=("toadd.do")' type="button" id="add" value="添加员工"/> --> </form> </div> </div> <b>资源列表</b> <table style="margin-bottom: 30px;" width="100%" border="1px" cellpadding="9" cellspacing="0"> <tr class="text"> <td width="10%" align="center">编号</td> <td width="10%" align="center">姓名</td> <td width="10%" align="center">等级</td> <td width="10%" align="center">工作年限</td> <td width="10%" align="center">入职时间</td> <td align="center" width="10%">操作</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('确定要删除吗?')" >删除</a> <a href="toupdate.do?id=${dever.devId}" >修改</a> </td> </tr> </c:forEach> </table> <b>添加人员</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>姓名:</td> <td> <input type="text" name="devName" class="cc" placeholder="请输入姓名" id="" value="" /> </td> </tr> <tr style="height:40px;"> <td>等级:</td> <td> <select id="STATUS" name="devLevel" > <option value = "高级" >高级</option> <option value = "中级" >中级</option> <option value = "初级" >初级</option> </select> </td> </tr> <tr style="height:40px;"> <td>工作年限:</td> <td> <input type="text" name="devWorkYear" class="cc" placeholder="请输入工作年限" id="" value="" /> </td> </tr> <tr style="height:40px;"> <td>入职时间:</td> <td> <input type="date" name="devInYear" class="cc" placeholder="请输入入职时间" id="" value="" /> </td> </tr> <tr style="height:40px;"> <td class="btn" colspan="2"> <input class="submit_btn" type="submit" value="确认添加"/> <input class="cancel_btn" type="button" onclick="history.back(-1)" value="取消"/> </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>修改信息</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"> 修改 </p> <form:form modelAttribute="upadtetbDever" id="addform" action="upDev.do" method="post"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td>姓名:</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>等级:</td> <td> <select id="STATUS" name="devLevel" > <option <c:if test="${tbDever.devLevel=='高级' }">selected="selected"</c:if> value = "高级" >高级</option> <option <c:if test="${tbDever.devLevel=='中级' }">selected="selected"</c:if> value = "中级" >中级</option> <option <c:if test="${tbDever.devLevel=='初级' }">selected="selected"</c:if> value = "初级" >初级</option> </select> </td> </tr> <tr> <td>工作年限:</td> <td> <input type="text" name="devWorkYear" class="cc" id="" value="${tbDever.devWorkYear }" /> </td> </tr> <tr> <td>入职时间:</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="确认修改"/> <input class="cancel_btn" type="button" onclick="history.back(-1)" value="取消"/> </td> </tr> </table> </form:form> </div> </body> </html>