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>

 

posted @ 2020-12-07 17:28  八块腹肌的青书  阅读(1285)  评论(0编辑  收藏  举报
Live2D