我是spring的新手,我已经尝试过编写一个原型。
我试着做了一个表单。每当我按下submit按钮时,什么都不会发生。我使用的是Spring Boot 2.4.3和Oracle OpenJDK 15.0.2。我试过火狐和Chrome。js-console为空。
这是我的模型(
):
public class Patient implements Serializable {
private long id;
private String firstname;
private String lastname;
// Geters and seters
}我的控制器(
):
@Controller
public class PatientController {
@GetMapping("/patient")
public String patientForm(Model model) {
model.addAttribute("patient", new Patient());
return "addPatient";
}
@PostMapping("/patient")
public String patientSubmit(@ModelAttribute("patient") Patient patient, Model model) {
model.addAttribute("patient", patient);
return "addedPatient";
}
}我的
HTL-Testet Prototype
Add a patient
Id:
Firstname:
Lastname :
Register我的
HTL-Testet Prototype
Add a patient
Add another patient发布于 2021-03-02 02:26:10
The The The
标签上的
佩奇错了
如果将其更改为
标签如下,问题就解决了:
HTL-Testet Prototype
Add a patient
Id:
Firstname:
Lastname :
Registerhttps://stackoverflow.com/questions/66423868
复制相似问题