亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Spring Boot集成FreeMarker 時(shí)訪問(wèn)不到.ftl文件的配置步驟

 更新時(shí)間:2025年04月23日 10:47:24   作者:旅行的獅子  
Spring Boot 要集成 FreeMarker 模板引擎時(shí)必須經(jīng)過(guò)正確的配置,大致可分為5 個(gè)步驟,下面分步驟給大家介紹的非常詳細(xì),感興趣的朋友一起看看吧

Spring Boot 項(xiàng)目集成 FreeMarker時(shí),未進(jìn)行正確配置的話會(huì)出現(xiàn)404錯(cuò)誤,如圖所示:

Spring Boot 要集成 FreeMarker 模板引擎時(shí)必須經(jīng)過(guò)正確的配置,大致可分為5 個(gè)步驟:

引入依賴(lài)

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
 </dependency>

在application.yml文件中進(jìn)行如下配置,務(wù)必配置正確(.properties文件也一樣)

  freemarker:
    template-loader-path: classpath:/templates  # classpath:  一定不能漏寫(xiě)
    cache: false
    charset: UTF-8
    check-template-location: true
    content-type: text/html
    expose-request-attributes: false
    expose-session-attributes: false
    request-context-attribute: req
    suffix: .ftl

曾經(jīng)因?yàn)槁?xiě) classpath: ,花了1個(gè)小時(shí)找不到原因

編寫(xiě)controller類(lèi)

@Controller
@RequestMapping("/")
public class OrderController {
    @GetMapping("/list")
    public ModelAndView list(Map<String, Object> map) {
        map.put("name", "chenf24k");
        return new ModelAndView("name", map);
    }
}

在Spring Boot項(xiàng)目的resources/templates下新建 name.ftl模板文件

<h1>FreeMarker</h1>
<h2>${name}</h2>

啟動(dòng)Spring Boot 項(xiàng)目后瀏覽器輸入地址: http://127.0.0.1:8080/list 進(jìn)行訪問(wèn)。

到此這篇關(guān)于Spring Boot集成FreeMarker 時(shí)訪問(wèn)不到.ftl文件的配置步驟的文章就介紹到這了,更多相關(guān)Spring Boot訪問(wèn)不到.ftl文件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論