Java sts控制台中没有错误消息的白标错误页

Java sts控制台中没有错误消息的白标错误页,java,spring-boot,thymeleaf,sts,Java,Spring Boot,Thymeleaf,Sts,在《行动中的春天》(Spring in action,第五版)一书出版之后,我正处于制作基本应用程序的第一步。但现在我在浏览器中看到以下错误消息,并且控制台中没有打印日志。代码如下: 控制器方法: @Controller @RequestMapping("/design") public class DesignTacoController { @GetMapping public String showDesignForm(Model model) {

在《行动中的春天》(Spring in action,第五版)一书出版之后,我正处于制作基本应用程序的第一步。但现在我在浏览器中看到以下错误消息,并且控制台中没有打印日志。代码如下:

控制器方法:

@Controller
@RequestMapping("/design")
public class DesignTacoController {
    @GetMapping  
    public String showDesignForm(Model model) {   
        List<Ingredient> ingredients = Arrays.asList(new Ingredient("FLTO", "Flour Tortilla", Ingredient.Type.WRAP),
                new Ingredient("COTO", "Corn Tortilla", Ingredient.Type.WRAP),
                new Ingredient("GRBF", "Ground Beef", Ingredient.Type.PROTEIN),
                new Ingredient("CARN", "Carnitas", Ingredient.Type.PROTEIN),
                new Ingredient("TMTO", "Diced Tomatoes", Ingredient.Type.VEGGIES),
                new Ingredient("LETC", "Lettuce", Ingredient.Type.VEGGIES),
                new Ingredient("CHED", "Cheddar", Ingredient.Type.CHEESE),
                new Ingredient("JACK", "Monterrey Jack", Ingredient.Type.CHEESE),
                new Ingredient("SLSA", "Salsa", Ingredient.Type.SAUCE),
                new Ingredient("SRCR", "Sour Cream", Ingredient.Type.SAUCE));
        Type[] types = Ingredient.Type.values();
            for (Type type : types) {
                model.addAttribute(type.toString().toLowerCase(), 
                filterByType(ingredients, type));    
                }    
        model.addAttribute("tacodesign", new Taco());    
        return "tacodesign";  
        }

    private List<Ingredient> filterByType(List<Ingredient> ingredients, Type type) {
        return ingredients.stream().filter(x -> x.getType().equals(type)).collect(Collectors.toList());  
        }
    
    @Bean
    public ViewResolver getViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("templates/");
        //resolver.setSuffix(".html");
        return resolver;
    }
查看(使用thymeleaf):

下面是文件夹结构的屏幕截图:

错误的屏幕截图:

我从下面的链接中获取了一些输入,它确实帮助我删除了旧的错误,但现在我仍然坚持这个错误。
问题在于,您需要提供正确的模板作为控制器中
showDesignForm
的返回值

请返回
TacoHome
而不是
tacodesign

@GetMapping
公共字符串showDesignForm(模型){
列出配料=数组.asList(新配料(“FLTO”、“面粉玉米饼”、配料.Type.WRAP),
新配料(“科托”、“玉米饼”、配料、类型、包装),
新成分(“GRBF”、“碎牛肉”、成分、类型、蛋白质),
新成分(“CARN”、“Carnitas”、成分、类型、蛋白质),
新配料(“TMTO”,“番茄丁”,配料类型,蔬菜),
新配料(“LETC”、“莴苣”、配料、类型、蔬菜),
新配料(“CHED”、“Cheddar”、配料类型、奶酪),
新配料(“杰克”、“蒙特雷杰克”、配料、类型、奶酪),
新配料(“SLSA”、“萨尔萨”、配料、类型、酱汁),
新配料(“SRCR”、“酸奶油”、配料类型、酱汁);
Type[]types=component.Type.values();
对于(类型:类型){
model.addAttribute(type.toString().toLowerCase(),
过滤器类型(成分、类型);
}    
addAttribute(“tacodesign”,new Taco());
//将模板名称设置为适当的值
//一般来说,它应该与中的文件名匹配
//模板目录,不带扩展名
返回“塔科霍姆”;
}

问题在于,您需要提供正确的模板作为控制器中
showDesignForm
的返回值

请返回
TacoHome
而不是
tacodesign

@GetMapping
公共字符串showDesignForm(模型){
列出配料=数组.asList(新配料(“FLTO”、“面粉玉米饼”、配料.Type.WRAP),
新配料(“科托”、“玉米饼”、配料、类型、包装),
新成分(“GRBF”、“碎牛肉”、成分、类型、蛋白质),
新成分(“CARN”、“Carnitas”、成分、类型、蛋白质),
新配料(“TMTO”,“番茄丁”,配料类型,蔬菜),
新配料(“LETC”、“莴苣”、配料、类型、蔬菜),
新配料(“CHED”、“Cheddar”、配料类型、奶酪),
新配料(“杰克”、“蒙特雷杰克”、配料、类型、奶酪),
新配料(“SLSA”、“萨尔萨”、配料、类型、酱汁),
新配料(“SRCR”、“酸奶油”、配料类型、酱汁);
Type[]types=component.Type.values();
对于(类型:类型){
model.addAttribute(type.toString().toLowerCase(),
过滤器类型(成分、类型);
}    
addAttribute(“tacodesign”,new Taco());
//将模板名称设置为适当的值
//一般来说,它应该与中的文件名匹配
//模板目录,不带扩展名
返回“塔科霍姆”;
}

我尝试了该解决方案,但仍然得到相同的错误。以前,我尝试重命名视图以匹配上一次返回,但在这两种情况下都会出现现有错误。很抱歉,在另一篇文章的回答中,它被要求在application.properties中添加以下内容:spring.thymeleaf.enabled=false我已删除,现在我已正确获取视图。谢谢欢迎@AbhinashJha。没有必要道歉。我很高兴现在应用程序工作正常。我尝试了解决方案,但仍然得到相同的错误。以前,我尝试重命名视图以匹配上一次返回,但在这两种情况下都会出现现有错误。很抱歉,在另一篇文章的回答中,它被要求在application.properties中添加以下内容:spring.thymeleaf.enabled=false我已删除,现在我已正确获取视图。谢谢欢迎@AbhinashJha。没有必要道歉。我很高兴看到应用程序运行正常。
package com.example.demo.taco.model;

import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class Ingredient {
    private String id;
    private String name;
    private Type type;

    public static enum Type {
        WRAP, PROTEIN, VEGGIES, CHEESE, SAUCE
    }

    public Ingredient(String id, String name, Type type) {
        this.id = id;
        this.name = name;
        this.type = type;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Type getType() {
        return type;
    }
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:th="http://www.thymeleaf.org" 
    xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
    xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Taco Cloud</title>
<link rel="stylesheet" th:href="@{/styles.css}" />
</head>
<body>
    <h1>Design your taco!</h1>
    <img th:src="@{/images/TacoCloud.png}" />
    <form method="POST" th:object="${tacodesign}">
        <div class="grid">
            <div class="ingredient-group" id="wraps">
                <h3>Designate your wrap:</h3>
                <div th:each="ingredient : ${wrap}">
                    <input name="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 name="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 name="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 name="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 name="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>
package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class TacoCloudApplication {

    public static void main(String[] args) {
        SpringApplication.run(TacoCloudApplication.class, args);
    }

}