我怎样才能正确地从表单中获取数据
How can i getting data from the form correctly
例如,我有实体 User
我应该在数据对象中使用什么 class 作为良好实践:
它应该是 User 或者 RegistrationForm 或 UserDTO 从表单中获取数据的最佳解决方案是什么?
<form method=POST data-th-object=${what is good practice for use there} data-th-action=@{/registration}>
//some data
</form>
我个人喜欢使用专用的表单数据对象,而不是表单中的实体本身,以便更清楚地分离关注点。我在 https://www.wimdeblauwe.com/blog/2021/05/23/form-handling-with-thymeleaf/
中对此进行了更详细的解释
例如,我有实体 User
我应该在数据对象中使用什么 class 作为良好实践: 它应该是 User 或者 RegistrationForm 或 UserDTO 从表单中获取数据的最佳解决方案是什么?
<form method=POST data-th-object=${what is good practice for use there} data-th-action=@{/registration}>
//some data
</form>
我个人喜欢使用专用的表单数据对象,而不是表单中的实体本身,以便更清楚地分离关注点。我在 https://www.wimdeblauwe.com/blog/2021/05/23/form-handling-with-thymeleaf/
中对此进行了更详细的解释