Spring MVC从未提交中删除
我是spring的新手,我尝试过编写一个原型 我试过做一个表格。每当我按下submit按钮时,什么都不会发生。 我在Oracle OpenJDK 15.0.2中使用Spring Boot 2.4.3。我试过Firefox和Chrome。js控制台是空的 这是我的模型(Spring MVC从未提交中删除,spring,forms,spring-mvc,thymeleaf,Spring,Forms,Spring Mvc,Thymeleaf,我是spring的新手,我尝试过编写一个原型 我试过做一个表格。每当我按下submit按钮时,什么都不会发生。 我在Oracle OpenJDK 15.0.2中使用Spring Boot 2.4.3。我试过Firefox和Chrome。js控制台是空的 这是我的模型(Patient.java): 我的控制器(PatientController.java): 我的addPatient.html: <!DOCTYPE html> <html xmlns:th="https
Patient.java
):
我的控制器(PatientController.java
):
我的addPatient.html
:
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTL-Testet Prototype</title>
</head>
<body>
<h1>Add a patient</h1>
<from action="#" th:action="@{/patient}" th:object="${patient}" method="post">
<p>Id: <input type="number" th:field="*{id}"/></p>
<p>Firstname: <input type="text" th:field="*{firstname}"/></p>
<p>Lastname : <input type="text" th:field="*{lastname}"/></p>
<button type="submit">Register</button>
</from>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTL-Testet Prototype</title>
</head>
<body>
<h1>Add a patient</h1>
<p th:text="'Added ' + '[' + ${patient.id} + ']' + ${patient.firstname} + ' ' + ${patient.lastname}"></p>
<a href="/patient">Add another patient</a>
</body>
</html>
addPatient.hmtl
页面上的from
标记错误,如果将其更改为form
标记,则问题已解决:
HTL测试仪原型
添加患者
身份证:
名字:
姓氏:
登记
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTL-Testet Prototype</title>
</head>
<body>
<h1>Add a patient</h1>
<from action="#" th:action="@{/patient}" th:object="${patient}" method="post">
<p>Id: <input type="number" th:field="*{id}"/></p>
<p>Firstname: <input type="text" th:field="*{firstname}"/></p>
<p>Lastname : <input type="text" th:field="*{lastname}"/></p>
<button type="submit">Register</button>
</from>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>HTL-Testet Prototype</title>
</head>
<body>
<h1>Add a patient</h1>
<p th:text="'Added ' + '[' + ${patient.id} + ']' + ${patient.firstname} + ' ' + ${patient.lastname}"></p>
<a href="/patient">Add another patient</a>
</body>
</html>