html页面其中有添加员工的,Springboot:员工管理之添加员工(十(7))

构建员工添加请求

com\springboot\controller\EmployeeController.java

/*调转到员工添加页 携带部门信息 restful风格*/

@GetMapping("/emp")

public String toAddPage(Model model){

//获取所有的部门

Collection 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

添加员工

构建添加页面

resources\templates\add.html

form表单:

姓名

邮箱

性别

部门

th:value="${dept.getId()}"

th:text="${dept.getDepartmentName()}">

生日

添加

日期格式设置

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

spring:

mvc:

date-format: yyyy-MM-dd

测试访问:

添加:

6c2474ae37288d383cef4f92511df96e.png

列表显示:

9d61416f69ec95e2334d19bf84620445.png

原文:https://www.cnblogs.com/applesnt/p/12686587.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值