我正在学习弹簧靴。我创建了这个超级简单的项目,但是当我尝试返回带有 @GetMapping 注释的 HTML 页面时,我不断收到 404 Whitelabel 错误页面。
这是我唯一的控制器:
package com.example.springplay;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class MainController {
@GetMapping(value = "/")
public String hello(){
return "hello";
}
}
这是弹簧应用程序:
package com.example.springplay;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringplayApplication {
public static void main(String[] args) {
SpringApplication.run(SpringplayApplication.class, args);
}
}
这是 hello.html 页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
hello.html页面在resources/templates文件夹下,不知道怎么回事。我从另一个工作项目中复制了具有完全相同结构的这部分,但我的只是给了我这个 Whitelabel 错误页面。