Java Spring启动应用程序白标签错误页

Java Spring启动应用程序白标签错误页,java,spring-boot,maven,Java,Spring Boot,Maven,我的springboot应用程序出现了404页的白标签错误。我正在硬编码一个学生名单,他们应该作为名字的基础弹出页面。我尝试了使用模板的不同方法,但似乎没有任何效果。我也尝试了/*端点,但也没有任何效果。我找不到此问题的任何相关问题来解决我的问题。这些是不同的阶级 控制器 public class StudentController { private List<Student> studentList = new ArrayList<>(); @GetMapping

我的springboot应用程序出现了404页的白标签错误。我正在硬编码一个学生名单,他们应该作为名字的基础弹出页面。我尝试了使用模板的不同方法,但似乎没有任何效果。我也尝试了/*端点,但也没有任何效果。我找不到此问题的任何相关问题来解决我的问题。这些是不同的阶级

控制器

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
    注释

请也共享配置。将类设为@RestController,然后重试。。还可以共享您正在尝试的URL以及您在日志中看到的错误。共享配置会有帮助我显然是个白痴。完全忘记了控制器注释。它解决了我的问题谢谢!:)
<!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>