Getting White Lable Error with This application has no explicit mapping for /error, so you are seeing this as a fallback in Spring boot

huangapple 未分类评论56阅读模式
标题翻译

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 -->

&lt;!DOCTYPE html&gt;
&lt;html 
      xmlns:th=&quot;http://www.thymeleaf.org&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Taco Cloud&lt;/title&gt;
    
  &lt;/head&gt;

  &lt;body&gt;
    &lt;h1&gt;Design your taco!&lt;/h1&gt;
    

    &lt;form method=&quot;POST&quot; th:object=&quot;${design}&quot;&gt;
    &lt;div class=&quot;grid&quot;&gt;
      &lt;div class=&quot;ingredient-group&quot; id=&quot;wraps&quot;&gt;
      &lt;h3&gt;Designate your wrap:&lt;/h3&gt;
      &lt;div th:each=&quot;ingredient : ${wrap}&quot;&gt;
        &lt;input th:field=&quot;*{ingredients}&quot; type=&quot;checkbox&quot;
               th:value=&quot;${ingredient.id}&quot;/&gt;
        &lt;span th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;/div&gt;

          &lt;div class=&quot;ingredient-group&quot; id=&quot;proteins&quot;&gt;
      &lt;h3&gt;Pick your protein:&lt;/h3&gt;
      &lt;div th:each=&quot;ingredient : ${protein}&quot;&gt;
        &lt;input th:field=&quot;*{ingredients}&quot; type=&quot;checkbox&quot;
               th:value=&quot;${ingredient.id}&quot;/&gt;
        &lt;span th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;/div&gt;

          &lt;div class=&quot;ingredient-group&quot; id=&quot;cheeses&quot;&gt;
      &lt;h3&gt;Choose your cheese:&lt;/h3&gt;
      &lt;div th:each=&quot;ingredient : ${cheese}&quot;&gt;
        &lt;input th:field=&quot;*{ingredients}&quot; type=&quot;checkbox&quot;
               th:value=&quot;${ingredient.id}&quot;/&gt;
        &lt;span th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;/div&gt;

          &lt;div class=&quot;ingredient-group&quot; id=&quot;veggies&quot;&gt;
      &lt;h3&gt;Determine your veggies:&lt;/h3&gt;
      &lt;div th:each=&quot;ingredient : ${veggies}&quot;&gt;
        &lt;input th:field=&quot;*{ingredients}&quot; type=&quot;checkbox&quot;
               th:value=&quot;${ingredient.id}&quot;/&gt;
        &lt;span th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;/div&gt;

          &lt;div class=&quot;ingredient-group&quot; id=&quot;sauces&quot;&gt;
      &lt;h3&gt;Select your sauce:&lt;/h3&gt;
      &lt;div th:each=&quot;ingredient : ${sauce}&quot;&gt;
        &lt;input th:field=&quot;*{ingredients}&quot; type=&quot;checkbox&quot;
               th:value=&quot;${ingredient.id}&quot;/&gt;
        &lt;span th:text=&quot;${ingredient.name}&quot;&gt;INGREDIENT&lt;/span&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;

      &lt;div&gt;


      &lt;h3&gt;Name your taco creation:&lt;/h3&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{name}&quot;/&gt;
      &lt;br/&gt;

      &lt;button&gt;Submit Your Taco&lt;/button&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

And I am getting following error:

enter image description here

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:

 &lt;form method=&quot;POST&quot; th:object=&quot;${design}&quot; th:action=&quot;@{taco/save}&quot;&gt;

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/

huangapple
  • 本文由 发表于 2020年5月30日 14:09:53
  • 转载请务必保留本文链接:https://java.coder-hub.com/62098557.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定