Spring - 无法解析 MVC“视图”thymeleaf

2023-11-23

我有一个简单的HomeController.class:

package com.example.tacos;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class HomeController {

    @GetMapping("/")
    public String home() {
        return "home";
    }
}

我还得到了一个名为home.html

<!DOCTYPE HTML>
    <head>
    <title>Getting Started: Serving Web Content</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
        <p>Hey</p>
    </body>
</html>

不管怎样,我在浏览器中收到 404 错误,IDE 告诉我无法解析 MVC“视图”,正如您在屏幕上看到的那样

Folder Structure: Folder Structure

Browser: Browser


您好,我遇到了同样的问题,我通过删除 Thymeleaf 的版本来修复它,因此 pom 文件将如下所示:

 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring - 无法解析 MVC“视图”thymeleaf 的相关文章

随机推荐