Java Spring启动应用程序白标签错误页
我的springboot应用程序出现了404页的白标签错误。我正在硬编码一个学生名单,他们应该作为名字的基础弹出页面。我尝试了使用模板的不同方法,但似乎没有任何效果。我也尝试了/*端点,但也没有任何效果。我找不到此问题的任何相关问题来解决我的问题。这些是不同的阶级 控制器Java Spring启动应用程序白标签错误页,java,spring-boot,maven,Java,Spring Boot,Maven,我的springboot应用程序出现了404页的白标签错误。我正在硬编码一个学生名单,他们应该作为名字的基础弹出页面。我尝试了使用模板的不同方法,但似乎没有任何效果。我也尝试了/*端点,但也没有任何效果。我找不到此问题的任何相关问题来解决我的问题。这些是不同的阶级 控制器 public class StudentController { private List<Student> studentList = new ArrayList<>(); @GetMapping
public class StudentController {
private List<Student> studentList = new ArrayList<>();
@GetMapping("/hello")
public String friendListing(Model model) {
Student student1 = new Student("Kate", "Cole");
studentList.add(student1);
Student student2 = new Student("Dan", "Brown");
studentList.add(student2);
Student student3 = new Student("Mike", "Mars");
studentList.add(student3);
model.addAttribute("studentList", studentList);
return "hello";
}}
和观点
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Server Programming with Spring Boot</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<tr th:each="student: ${studentList}">
<td th:text="${student.firstName}"></td>
</tr>
</body>
</html>
使用Spring引导进行服务器编程
您的主要应用程序类在哪里
- 在控制器类包中使用
注释@ComponentScan
- 控制器类应具有
注释@Controller
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Server Programming with Spring Boot</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<tr th:each="student: ${studentList}">
<td th:text="${student.firstName}"></td>
</tr>
</body>
</html>