Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring MVC从未提交中删除_Spring_Forms_Spring Mvc_Thymeleaf - Fatal编程技术网

Spring MVC从未提交中删除

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

我是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://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>