java - 我怎样才能正确地从表单中获取数据
问题描述
例如,我有实体用户
我应该在 data-th-object 中使用什么类以获得良好的实践:它应该是 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/上更详细地解释了这一点
推荐阅读
- html - 如何启用文件夹上传到
我正在做一个小项目,我的访问者可以上传他们的文件、图像等,一旦他们点击“发送”按钮,它就会将他们上传的内容发送到我设置的电子邮件地址。现在这里的问题是,如果访问者上传例如 5 个文件,它只会随机发送这 5 个文件中的一个,我希望它发送所有文件,那么有没有办法实现这一点?
我想我可以通过使文件上传字段接受文件夹来做到这一点,但我不确定如何准确地做到这一点,我知道我可以将文件夹
- excel - 将输入框变量从一个子传递到另一个
- jquery - 带有 webpack 的 daterangepicker 失败
- reactjs - 如何测试 Stripe 与 React 测试库的集成。无法渲染卡片元素
- powershell - 远程 PowerShell 时出现错误 Connect-MsolService
- javascript - 使用 mp3 音频在 Next 中切换播放/暂停按钮
- javascript - ReferenceError:赋值/语法错误中的左侧无效
- c# - 替代使用不区分大小写的比较器的 System.Web.HttpUtility.ParseQueryString?
- apache2 - cgi 文件无法从浏览器执行反引号命令
- laravel - How to Select from SubQuery using distinct in Laravels