标题翻译
Getting White Lable Error with This application has no explicit mapping for /error, so you are seeing this as a fallback in Spring boot
问题
以下是您提供的内容的中文翻译:
我正在使用Spring Boot。我正在尝试使用Thymeleaf模板。我已经使用了Lombok。在运行项目时,我遇到了一个WhiteLabel错误,错误信息是:在模板解析过程中发生意外错误(类型=内部服务器错误,状态=500)。
在模板解析过程中发生错误(模板:“class path resource [templates/design.html ]”)
org.thymeleaf.exceptions.TemplateInputException:在模板解析过程中发生错误(模板:“class path resource [templates/design.html ]”)
这是我的项目结构
插入图像描述
<!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>
<!-- 其他类似的ingredient-group部分 -->
<div>
<h3>Name your taco creation:</h3>
<input type="text" th:field="*{name}"/><br/>
<button>Submit Your Taco</button>
</div>
</div>
</form>
</body>
</html>
我遇到了以下错误:
我正在努力学习Spring Boot。非常感谢您的帮助。
英文翻译
I am using Spring boot. I am trying to use thymeleaf template. I have used lombok. I am getting WhiteLabel error while running the project that says There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "class path resource [templates/design.html ]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/design.html ]")
This is my project structure
enter image description here
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!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>
<!-- end snippet -->
And I am getting following error:
I am trying to learn Spring boot. Your help will be highly appreciated
答案1
得分: 0
你需要编写一个表单操作:
<form method="POST" th:object="${design}" th:action="@{taco/save}">
WhiteLabel Error Page 是一个通用的 Spring Boot 错误页面,当没有自定义错误页面时显示。因此,您需要为状态码为 500 的错误设置一个页面:
http://zetcode.com/springboot/whitelabelerror/
英文翻译
You need to code a form action:
<form method="POST" th:object="${design}" th:action="@{taco/save}">
WhiteLabel Error Page is a generic Spring Boot error page that is displayed when no custom error page is present. So you need to setup a page for status 500 error:
http://zetcode.com/springboot/whitelabelerror/
专注分享java语言的经验与见解,让所有开发者获益!
评论