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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM