1,在重用的页面区分是添加还是修改,用 ${emp!=null} 判断
<input name="lastName" type="text" th:value="${emp!=null}?${emp.lastName}">
2,页面创建一个post表单,添加用post请求,修改用put请求,创建一个input项,name="_method";值就是指定的请求方式
<form th:action="@{/emp}" method="post">
<input type="hidden" name="_method" value="put" th:if="${emp!=null}"/>
<input type="hidden" name="id" th:if="${emp!=null}" th:value="${emp.id}">
.....
</form>
3,根据判断结果,决定是否启用 input 标签
<form th:action="@{/emp}" method=