我正在使用 Spring 启动。我正在尝试使用 thymeleaf 模板。我用过 Lombok 。我在运行项目时收到 WhiteLabel 错误,提示有意外错误(类型=内部服务器错误,状态=500)。 模板解析时发生错误(模板:“类路径资源[templates/design.html]”) org.thymeleaf.exceptions.TemplateInputException:模板解析时发生错误(模板:“类路径资源[templates/design.html]”)
这是我的项目结构 enter image description here
<!DOCTYPE html>
<html
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Taco Cloud</title>
</head>
<body>
<h1>Design your taco!</h1>
<form method="POST" th:object="${design}">
<div class="grid">
<div class="ingredient-group" id="wraps">
<h3>Designate your wrap:</h3>
<div th:each="ingredient : ${wrap}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
</div>
<div class="ingredient-group" id="proteins">
<h3>Pick your protein:</h3>
<div th:each="ingredient : ${protein}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
</div>
<div class="ingredient-group" id="cheeses">
<h3>Choose your cheese:</h3>
<div th:each="ingredient : ${cheese}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
</div>
<div class="ingredient-group" id="veggies">
<h3>Determine your veggies:</h3>
<div th:each="ingredient : ${veggies}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
</div>
<div class="ingredient-group" id="sauces">
<h3>Select your sauce:</h3>
<div th:each="ingredient : ${sauce}">
<input th:field="*{ingredients}" type="checkbox"
th:value="${ingredient.id}"/>
<span th:text="${ingredient.name}">INGREDIENT</span><br/>
</div>
</div>
</div>
<div>
<h3>Name your taco creation:</h3>
<input type="text" th:field="*{name}"/>
<br/>
<button>Submit Your Taco</button>
</div>
</form>
</body>
</html>
我收到以下错误:
我正在尝试学习Spring boot。我们将非常感谢您的帮助
最佳答案
您需要编写表单操作代码:
<form method="POST" th:object="${design}" th:action="@{taco/save}">
WhiteLabel 错误页面是通用 Spring Boot 错误页面,在不存在自定义错误页面时显示。所以你需要为状态 500 错误设置一个页面: http://zetcode.com/springboot/whitelabelerror/
关于java - 此应用程序出现白色标签错误没有明确的/错误映射,因此您将其视为 Spring boot 中的后备方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62098557/