Vad*_*tov 3 spring spring-mvc thymeleaf spring-boot
我得到了一个简单的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";
}
}
Run Code Online (Sandbox Code Playgroud)
我也有一个模板叫做 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>
Run Code Online (Sandbox Code Playgroud)
无论如何,我在浏览器中得到 404,IDE 告诉我无法解析 MVC“视图”,正如您在屏幕上看到的那样
小智 6
要解决此问题,您应该添加web app打包到 Web 资源目录中的路径。
小智 5
嗨,我遇到了同样的问题,我通过删除 Thymeleaf 的版本来修复它,因此 pom 文件将如下所示:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5818 次 |
| 最近记录: |