public class User {
private String username;
private String password;
private String email;
// getter and setter methods here
// other methods here
}
html
<form>
<input type="text" id="username" name="username" value="${user.username}" />
<input type="password" id="password" name="password" value="${user.password}" />
<input type="email" id="email" name="email" value="${user.email}" />
</form>
public class RegistrationController {
public void submitForm(User user) {
}
}
@Controller
public class RegistrationController {
@GetMapping("/register")
public String showRegistrationForm(Model model) {
model.addAttribute("user", new User());
return "registrationForm";
}
@PostMapping("/register")
public String submitForm(@ModelAttribute("user") User user) {
return "registrationSuccess";
}
}