SpringBoot+SpringMvc页面跳转404问题

当我们使用ModelAndView进行页面跳转出现404,有以下几个原因:

1.modelAndView包引入错误,正确的包应该是( org.springframework.web.servlet.ModelAndView
2.配置文件中前后缀没有配置

spring: 
 freemarker:
    request-context-attribute: request
    prefix: /templates/
    suffix: .html
    content-type: text/html
    enabled: true
    cache: false
    charset: UTF-8

3.没有引入相关依赖

   缺少:

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
原文地址:https://www.cnblogs.com/mylqm/p/14098286.html