41、尚硅谷_SpringBoot_web开发-【实验】-员工添加-添加完成

添加员工数据

 //保存用户信息
    @PostMapping("/emp")
    public String saveEmployee(Employee employee) {
        System.out.println(employee);
        dao.save(employee);
        return "redirect:/emps";
    }

添加员工的html页面

	<form th:action="@{/emp}" method="post">
					<div class="form-group">
						<label>LastName</label>
						<input type="text" class="form-control" name="lastName" value="zhangsan">
					</div>
					<div class="form-group">
						<label>Email</label>
						<input type="email" name="email" class="form-control" value="zhangsan@atguigu.com">
					</div>
					<div class="form-group">
						<label>Gender</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>department</label>
						<select class="form-control" name="department.id">
							<option th:each="dep:${deparms}" th:value="${dep.id}" th:text="${dep.departmentName}">1</option>
						</select>
					</div>
					<div class="form-group">
						<label>Birth</label>
						<input type="text" class="form-control" name="birth" value="2019-7-5">
					</div>
					<button type="submit" class="btn btn-primary" >添加</button>
				</form>

提交的数据格式不对:生日:日期;

2017-12-12;2017/12/12;2017.12.12;

日期的格式化;SpringMVC将页面提交的值需要转换为指定的类型;

2017-12-12—Date; 类型转换,格式化;

默认日期是按照/的方式;

配置application.properties 文件,设置日期格式

spring.mvc.date-format=yyyy-MM-dd
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值