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