6、员工管理系统:准备工作
疑问代码
public class DepartmentDao {
// 模拟数据库中的数据
private static Map<Integer, Department> departments = null;
static {
departments=new HashMap<Integer,Department>();
departments.put(101,new Department(101,"教学部"));
departments.put(102,new Department(102,"市场部"));
departments.put(103,new Department(103,"教研部"));
departments.put(104,new Department(104,"运营部"));
departments.put(105,new Department(105,"后勤部"));
}
}
Map详解: https://blog.csdn.net/weixin_52385232/article/details/124347107
页面国际化,没有怎么听懂,有机会再听
【【狂神说Java】SpringBoot最新教程IDEA版通俗易懂】https://www.bilibili.com/video/BV1PE411i7CV?p=22&vd_source=a3b24290f09642136ab66aeedf2210b8

th td标签
点击查看代码
<thead>
<!-- tr 定义一行-->
<tr>
<!-- th 定义单元格内容加粗,td定义单元格-->
<th>id</th>
<th>lastName</th>
<th>email</th>
<th>gender</th>
<th>department</th>
<th>birth</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr th:each="emp:${emps}">
<td th:text="${emp.getId()}"></td>
<td th:text="${emp.getLastName()}"></td>
<td th:text="${emp.getEmail()}"></td>
<td th:text="${emp.getGender()}"></td>
<td th:text="${emp.department.getDepartmentName()}"></td>
<td th:text="${emp.getBirth()}"></td>
<td>
<button class="btn btn-sm btn-primary" >编辑</button>
<button class="btn btn-sm btn-danger" >删除</button>
</td>
</tr>
</tbody>
效果图

根据id修改就需要传入id ,然后在页面中隐藏
链接:https://blog.csdn.net/weixin_43901865/article/details/116672755
springboot 自动处理404页面
-
Thymeleaf模板自定义静态error页面方法:
在resource/templates/error下添加error.html页面(error替换成对应的错误码,404、401、500等,还可以用4xx、5xx等),springBoot会自动找到该页面作为错误页面,适合内嵌Tomcat或者war方式。SpringBoot错误视图提供了以下错误属性: -
timestamp:错误发生时间;
-
status:HTTP状态吗;
-
error:错误原因;
-
exception:异常的类名;
-
message:异常消息(如果这个错误是由异常引起的);
-
errors:BindingResult异常里的各种错误(如果这个错误是由异常引起的);
-
trace:异常跟踪信息(如果这个错误是由异常引起的);
-
path:错误发生时请求的URL路径。
————————————————
版权声明:本文为CSDN博主「普通网友」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/drnrrwfs/article/details/124403473
浙公网安备 33010602011771号