小编Prz*_*mek的帖子

尝试呈现index.html时,Spring Boot + Thymeleaf =“ Whitelabel错误页面”

我正在尝试做简单的Spring MVC库

您是否知道为什么我的View有问题,当我在控制器中使用主页方法时,应该向我显示index.html,但我一直都只收到Whitelabel Error Page,而我不知道为什么:/

我的结构:[ https://i.imgur.com/5TrGGrB.png]

我的控制器:

package controller;


import model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import service.BookService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@Controller
public class LiberianController{

    @Autowired
    private BookService bookService;


    @RequestMapping(value = "/")
    public String homepage() {
        return "index";
    }

    @GetMapping(value = "/allBooks")
    public ModelAndView allBooks(ModelAndView modelAndView) {
        List<Book> books = bookService.getAllBooks();
        modelAndView.addObject("listBooks", books);
        modelAndView.setViewName("allBooks");

        return modelAndView;
    }

    @GetMapping(value = "/addBook")
    public ModelAndView newBook(ModelAndView modelAndView) {
        Book book …
Run Code Online (Sandbox Code Playgroud)

spring maven thymeleaf spring-boot

2
推荐指数
1
解决办法
1346
查看次数

标签 统计

maven ×1

spring ×1

spring-boot ×1

thymeleaf ×1