spring-boot - 带有小胡子和弹簧错误标签的错误消息
问题描述
我从 Spring 中找到了以下文档来轻松验证表单。 https://github.com/spring-guides/gs-validating-form-input 现在我遇到的问题是无法将 Thymeleaf 错误标签与 Mustache 一起使用。有没有人有解决方案或想法?
这是文档中的解决方案
<html>
<body>
<form action="#" th:action="@{/}" th:object="${personForm}" method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" th:field="*{name}" /></td>
<td th:if="${#fields.hasErrors('name')}" th:errors="*{name}">Name Error</td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" th:field="*{age}" /></td>
<td th:if="${#fields.hasErrors('age')}" th:errors="*{age}">Age Error</td>
</tr>
<tr>
<td><button type="submit">Submit</button></td>
</tr>
</table>
</form>
</body>
</html>
我的 edit.mustache 文件的一部分
<form action="/event/save" enctype='multipart/form-data' method="post">
{{#event}}
<div class="form-row">
<div class="form-group col-md-6">
<label for="title">Name</label>
<input min="1" maxlength="60" type="text" class="form-control" id="title" name="title"
placeholder="Titel" required
value="{{title}}">
</div>
</div>
解决方案
推荐阅读
- mysql - 使用 student_id 显示学生出勤情况的单个查询
- c++ - 当一个人无权访问整个矩阵时,如何为矩阵分解编写乘法更新规则?
- node.js - 使用“httpntlm”在 React-Native 中进行 NTLM 身份验证
- amazon-web-services - 退出 0 后 jenkins 的工作需要很长时间才能进入下一步
- google-cloud-platform - Terraform:将文件复制到 GCP 计算实例
- java - @Autowire JpaRepository 接口类错误限定 bean
- groovy - 如何更改 Apache Camel Route 中的属性值?
- c - 如何在共享内存中写入变量或读取它们?
- sql - 比较不同记录之间的两个日期
- python - 哪种方式是在 python 中获取部分字符串的最佳方式?