本文介绍了Spring - 无法解析 MVC“视图"百里香叶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了一个简单的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视图"正如你在屏幕上看到的
Anyway I'm getting 404 in the browser and IDE's telling me Cannot resolve MVC "view" as you can see on the screen
文件夹结构:
浏览器:
推荐答案
我遇到了同样的问题,我通过删除 Thymeleaf 的版本来修复它,因此 pom 文件将如下所示:
Hi I had the same issue and I fixed it by delete the version of Thymeleaf so the pom file will be like :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
这篇关于Spring - 无法解析 MVC“视图"百里香叶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!