如何用wordpress快速建站,自己做网站用什么数据库,建网站可以用企业qq吗,有哪些做网站公司1 Freemarker 视图集成 SpringBoot 内部⽀持 Freemarker 视图技术的集成#xff0c;并提供了⾃动化配置类 FreeMarkerAuto Configuration#xff0c;借助⾃动化配置可以很⽅便的集成 Freemarker基础到 SpringBoot 环境中。这⾥借助⼊⻔项⽬引⼊ Freemarker 环境配置。
Start…1 Freemarker 视图集成 SpringBoot 内部⽀持 Freemarker 视图技术的集成并提供了⾃动化配置类 FreeMarkerAuto Configuration借助⾃动化配置可以很⽅便的集成 Freemarker基础到 SpringBoot 环境中。这⾥借助⼊⻔项⽬引⼊ Freemarker 环境配置。
Starter 坐标引⼊
dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-freemarker/artifactId
/dependency添加 Freemarker 配置信息 Freemarker 默认默认视图路径⽂ resources/templates ⽬录(由⾃动化配置类 Freemarker Properties 决定)该⽬录可以进⾏在 application.yml 中进⾏修改。 修改 application.yml 添加 freemarker 基本配置如下
spring:freemarker:suffix: .ftlcontent-type: text/htmlcharset: UTF-8template-loader-path: classpath:/views/
编写IndexController 控制器转发视图
package com.xxxx.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
Controller
public class IndexController {RequestMapping(index)public String index(){return index;}
}views ⽬录下添加 index.ftl 视图 2 Thymeleaf 视图集成 SpringBoot ⽀持多种视图技术集成并且 SpringBoot 官⽹推荐使⽤ Thymeleaf 作为前端视图⻚⾯这⾥实现Thymeleaf 视图集成借助⼊⻔项⽬引⼊ Thymeleaf 环境配置。
starter坐标引⼊
dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId
/dependency
添加 Thymeleaf 配置信息 hymeleaf 默认默认视图路径 resources/templates ⽬录(由⾃动化配置类 ThymeleafProperties 类决定)该⽬录可以进⾏在 application.yml 中进⾏修改。 ## 环境选择配置spring:thymeleaf:prefix: classpath:/html/## 关闭 thymeleaf ⻚⾯缓存cache: false编写 IndexController 控制器转发视图
Controller
public class IndexController {RequestMapping(index)public String index(Model model){// 设置请求域的值model.addAttribute(msg,Hello SpringBoot);return index;}
}
html ⽬录下添加 index.html 视图 修改 Thymeleaf 模板默认存放路径 (在 resources ⽬录下创建 html ⽂件夹)
!DOCTYPE html
html langen xmlns:thhttp://www.thymeleaf.org
headmeta charsetUTF-8titleThymeleaf视图/title
/head
body!-- 获取请求域的值 --h2 th:text${msg}/h2
/body
/html启动Starter访问