构建员工添加请求

com\springboot\controller\EmployeeController.java

/*调转到员工添加页 携带部门信息 restful风格*/
@GetMapping("/emp")
public String toAddPage(Model model){
//获取所有的部门
Collection<Department> departments = departmentDao.getDepartments();
model.addAttribute("departments",departments);
return "add";
} /*添加员工 restful风格*/
@PostMapping("/emp")
public String addEmp(Employee emp){
employeeDao.save(emp);
//重定向到员工列表请求
return "redirect:/employee";
}

在list.html增加添加员工按钮

resources\templates\list.html

<a class="btn btn-sm btn-primary" th:href="@{/emp}">添加员工</a>

构建添加页面

resources\templates\add.html

form表单:


<form th:action="@{/emp}" method="post"> <input type="hidden" name="id" />
<div class="form-group">
<label>姓名</label>
<input type="text" name="lastName" class="form-control" placeholder="zhangsan" >
</div>
<div class="form-group">
<label>邮箱</label>
<input type="email" name="email" class="form-control" placeholder="zhangsan@atguigu.com" >
</div>
<div class="form-group">
<label>性别</label><br/>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" value="1" >
<label class="form-check-label">男</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" value="0" >
<label class="form-check-label">女</label>
</div>
</div>
<div class="form-group">
<label>部门</label>
<select class="form-control" name="department.id" > <!--获取部门信息-->
<option th:each="dept:${departments}"
th:value="${dept.getId()}"
th:text="${dept.getDepartmentName()}">
</option> </select>
</div>
<div class="form-group">
<label>生日</label>
<input type="text" name="birth" class="form-control" placeholder="1986/02/22">
</div>
<button type="submit" class="btn btn-primary" >添加</button>
</form>

日期格式设置

springboot默认的时间格式为 yyyy/MM/dd 如果要用其他格式就需要在配置文件中配置:

spring:
mvc:
date-format: yyyy-MM-dd

测试访问:

添加:

列表显示:

Springboot:员工管理之添加员工(十(7))的更多相关文章

  1. Springboot:员工管理之删除员工及退出登录(十(9))

    springboot2.2.6 delete请求报错,降至2.1.11功能可用 原因未知 构建员工删除请求 com\springboot\controller\EmployeeController.j ...

  2. Springboot:员工管理之修改员工(十(8))

    构建员工修改请求 com\springboot\controller\EmployeeController.java /*调转到员工修改页 携带员工信息 restful风格*/ @GetMapping ...

  3. Springboot:员工管理之查询员工列表(十(6))

    构建员工controller com\springboot\controller\EmployeeController.java package com.springboot.controller; ...

  4. Springboot:员工管理之国际化(十(3))

    1:IDEA编码设置UTF-8 2:创建国际化文件 i18n\login.properties #默认语言 i18n\login_en_US.properties #英文语言 i18n\login_z ...

  5. Springboot:员工管理之首页(十(2))

    访问首页可以通过两种方式: 1:编写controller 2:自定义扩展视图解析器(推荐使用) 1:编写Controller com\springboot\controller\IndexContro ...

  6. 使用Jquery+EasyUI进行框架项目开发案例解说之中的一个---员工管理源代码分享

    使用Jquery+EasyUI 进行框架项目开发案例解说之中的一个 员工管理源代码分享 在開始解说之前,我们先来看一下什么是Jquery EasyUI?jQuery EasyUI是一组基于jQuery ...

  7. 使用Jquery+EasyUI项目开发情况的框架是中评---员工管理源代码共享

    使用Jquery+EasyUI 进行框架项目开发案例解说之中的一个 员工管理源代码分享 在開始解说之前,我们先来看一下什么是Jquery EasyUI?jQuery EasyUI是一组基于jQuery ...

  8. Springboot:员工管理之环境准备(十(1))

    1:静态资源 下载静态资源:https://files.cnblogs.com/files/applesnt/ztzy.zip 项目下载:https://files.cnblogs.com/files ...

  9. Springboot:员工管理之公共页面提取 高亮显示(十(5))

    把顶部和左侧的公共代码分别放到header.html和left.html中 顶部代码:resources\templates\header.html 主内容展示: <!DOCTYPE html& ...

随机推荐

  1. 发布内容需要的Markdown语法

    发布内容需要的Markdown语法 目录 发布内容需要的Markdown语法 [toc] 1.概述 1.1设计理念 1.2内联HTML语法 1.3特殊字符自动转义 2.行内语法讲解 2.1注释的表述 ...

  2. 百道Python面试题实现,搞定Python编程就靠它

    对于一般的机器学习求职者而言,最基础的就是掌握 Python 编程技巧,随后才是相关算法或知识点的掌握.在这篇文章中,我们将介绍一个 Python 练习题项目,它从算法练习题到机试实战题提供了众多问题 ...

  3. liunx 上安装redis

    目录 1.安装包 2.解压:tar xzf redis-5.0.5.tar.gz 3.安装 4.编辑redis.conf文件 5.配置密码 6.启动配置: 7.配置公网链接 8.杀掉redis进程 9 ...

  4. C++ 趣图

    一.心形 1. http://mathworld.wolfram.com/HeartCurve.html #include<stdio.h> using namespace std; in ...

  5. JavaScript数组的基本操作

    数组的创建方式: 方式一:构造函数构建数组 var arr = new Array ( ); 如果传入的参数为一个数字,代表数组的长度,不包含内容 // 可以传入字符串和数字,用逗号隔开,作为数组中的 ...

  6. Vue 【前端面试题】

    前言 看看面试题,只是为了查漏补缺,看看自己那些方面还不懂.切记不要以为背了面试题,就万事大吉了,最好是理解背后的原理,这样面试的时候才能侃侃而谈.不然,稍微有水平的面试官一看就能看出,是否有真才实学 ...

  7. CentOS-7.6 下搭建 NIS 服务器

    ##服务端配置: ####Server: 192.168.0.178(CentOS 7.6) # systemctl stop firewalld # systemctl disable firewa ...

  8. c语言 0与非0

    ------------恢复内容开始------------ 结论: 其它的编程语言中有布尔数据类型,并用百来表示逻辑真和逻辑假,C语言没有这个内置类度型,在C语言中真和假是用整型值来表示知的,0就表 ...

  9. 《Three.js 入门指南》3.1.1 - 基本几何形状 - 平面(PlaneGeometry)

    3.1 基本几何形状 平面(PlaneGeometry) 说明: 这里的平面(PlaneGeometry)其实是一个长方形,而不是数学意义上无限大小的平面. 构造函数: THREE.PlaneGeom ...

  10. 判断移动端还是PC端JS

    if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {         // alert("手机&qu ...