springboot 渲染web頁面

2021-08-19 08:03:27 字數 1530 閱讀 2926

spring boot提供了預設配置的模板引擎主要有以下幾種:

注意:避免使用jsp,jsp無法實現spring boot的多種特性;

org.springframework.bootgroupid>

spring-boot-starter-webartifactid>

dependency>

org.springframework.bootgroupid>

spring-boot-starter-tomcatartifactid>

dependency>

org.apache.tomcat.embedgroupid>

tomcat-embed-jasperartifactid>

dependency>

spring.mvc

.view

.prefix=/web-inf/jsp/

spring.mvc

.view

.suffix=.jsp

注意:記得對應建立目錄哦

1、pom檔案中

org.springframework.bootgroupid>

spring-boot-starter-freemarkerartifactid>

dependency>

spring.freemarker

.allow-request-override=false

spring.freemarker

.cache=true

spring.freemarker

.check-template-location=true

spring.freemarker

.charset=utf-8

spring.freemarker

.content-type=text/html

spring.freemarker

.expose-request-attributes=false

spring.freemarker

.expose-session-attributes=false

spring.freemarker

.expose-spring-macro-helpers=false

#spring.freemarker.prefix=

#spring.freemarker.request-context-attribute=

#spring.freemarker.settings.*=

spring.freemarker

.suffix=.ftl

spring.freemarker

.template-loader-path=classpath:/templates/#建立目錄

其他的按照原來那樣寫、ok

小結:

springboot剛剛接觸,目前感覺和spring差不多,所謂無知者無畏、我也不知道這麼所對不對,先這樣

web頁面渲染解析原理

使用者輸入 假設是個html頁面,並且是第一次訪問 瀏覽器向伺服器發出請求,伺服器返回html檔案 然後瀏覽器從head標籤開始逐行解析html 遇到link標籤又會向伺服器請求載入css檔案,不過這個過程是非同步的,有多個css檔案,會多個同時載入。繼續往後如果遇到script標籤或者js檔案就會...

web前端 之 渲染機制

dtd告訴瀏覽器我是什麼文件型別 瀏覽器根據文件型別來決定用什麼隱情引擎來渲染他 doctype就是告訴瀏覽器什麼是dtd的,通知瀏覽器告訴 當前文件包含的是哪個tb,也就是哪個文件型別,我們html中第一行的就是告訴瀏覽器文件型別是html 常見的doctype有哪些 那我們現在經常用的就是htm...

springboot 二 web綜合開發

配置spring controller掃瞄 對接的方法新增 responsebody 新增 configuration註解,將自定義filter加入過濾鏈 com.neo.description 分享生活和技術 create drop 每次載入hibernate時根據model類生成表,但是sess...