springboot整合freemarker

前提:css

開發工具:ideaweb

框架:spring boot、mavenspring

一、pom文件添加依賴mvc

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

二、新建spring web項目,會自動生成application.properties.app

使用application.properties配置文件以後,spring boot啓動時,會自動把配置信息讀取到spring容器中,並覆蓋spring boot的默認配置。框架

三、在配置文件中,設置如下兩個參數maven

 
#設定ftl文件路徑
spring.freemarker.template-loader-path=classpath:/templates
#設定靜態文件路徑,js,css
spring.mvc.static-path-pattern=/static/**

controller跳轉頁面以下:
templates/action/list.ftl頁面