spring.freemarker 2306

Springboot Properties 2306

>spring.freemarker 模板属性

NameDescriptionDefault Value

spring.freemarker.allow-request-override

Whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.

false

spring.freemarker.allow-session-override

Whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name.

false

spring.freemarker.cache

Whether to enable template caching.

false

spring.freemarker.charset

Template encoding.

UTF-8

spring.freemarker.check-template-location

Whether to check that the templates location exists.

true

spring.freemarker.content-type

Content-Type value.

text/html

spring.freemarker.enabled

Whether to enable MVC view resolution for this technology.

true

spring.freemarker.expose-request-attributes

Whether all request attributes should be added to the model prior to merging with the template.

false

spring.freemarker.expose-session-attributes

Whether all HttpSession attributes should be added to the model prior to merging with the template.

false

spring.freemarker.expose-spring-macro-helpers

Whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".

true

spring.freemarker.prefer-file-system-access

Whether to prefer file system access for template loading to enable hot detection of template changes. When a template path is detected as a directory, templates are loaded from the directory only and other matching classpath locations will not be considered.

false

spring.freemarker.prefix

Prefix that gets prepended to view names when building a URL.

spring.freemarker.request-context-attribute

Name of the RequestContext attribute for all views.

spring.freemarker.settings.*

Well-known FreeMarker keys which are passed to FreeMarker's Configuration.

spring.freemarker.suffix

Suffix that gets appended to view names when building a URL.

.ftlh

spring.freemarker.template-loader-path

Comma-separated list of template paths.

[classpath:/templates/]

spring.freemarker.view-names

View names that can be resolved.

###  是否启用freemarker , Whether to enable MVC view resolution for this technology? 默认 true
spring.freemarker.enabled: true



### 设定模板的前缀, 默认值是 	空白
spring.freemarker.prefix: 
### 设定模板的后缀, 默认值是 	.ftlh
spring.freemarker.suffix:

### Content-Type value.
######## 默认值为 text/html
#spring.freemarker.content-type: text/html
######## 当值不为 text/html时, 浏览器无法直接访问, 会显示404, 但同源ajax可以
#spring.freemarker.content-type: text/plain
#spring.freemarker.content-type: text/JavaScript

### 模板编码。 默认是 UTF-8
spring.freemarker.charset: UTF-8

### 设定模板的加载路径,多个以逗号分隔,默认: [classpath:/templates/]
spring.freemarker.template-loader-path: classpath:/templates/

### 是否检查模板位置是否存在。 默认是 true; 
spring.freemarker.check-template-location: false

### 是否启用模板缓存。 默认 false
spring.freemarker.cache: false

### 是否优先从文件系统加载模板,以支持热加载,默认为false
spring.freemarker.prefer-file-system-access: true




### 是否允许HttpServletRequest属性覆盖(隐藏)控制器生成的同名模型属性。 默认 false
spring.freemarker.allow-request-override: false

### 是否允许HttpSession属性覆盖(隐藏)控制器生成的同名模型属性。 默认false
spring.freemarker.allow-session-override: false


### 设定所有request的属性在merge到模板的时候,是否要都添加到model中. 默认false
spring.freemarker.expose-request-attributes: false

### 是否在merge模板的时候,将HttpSession属性都添加到model中, 默认false
spring.freemarker.expose-session-attributes: false

### 设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用, 默认true
spring.freemarker.expose-spring-macro-helpers: true


### views的白名单
### 可以解析view的清单(白名单) 默认不存在, 空白会阻止所有view , 开头有没有斜杠"/"必须和Controller的返回完全匹配
### spring.freemarker.view-names: 后面空白会阻止所有view, 一般可以去掉或注释掉, 下面是一些用法例子 可以用数组,也可以不用
#spring.freemarker.view-names: txt/txt.txt
#spring.freemarker.view-names: txt/txt.txt , txt/txt2.txt, 'ftl/ftl.ftl', "ftlh/ftlh.ftlh"
#spring.freemarker.view-names: [txt/txt.txt , txt/txt2.txt, ftl/ftl.ftl, ftlh/ftlh.ftlh]
#spring.freemarker.view-names: ['txt/txt.txt' , "txt/txt2.txt", ftl/ftl.ftl, ftlh/ftlh.ftlh]
#spring.freemarker.view-names:
# - 'txt/txt.txt'
# - "txt/txt2.txt"
# - ftl/ftl.ftl
# - ftlh/ftlh.ftlh
# - 可以加单双引号/也可以不加



### 设定FreeMarker keys.
spring.freemarker.settings.template_update_delay: 0
spring.freemarker.settings.default_encoding: UTF-8
spring.freemarker.settings.classic_compatible: true


是否启用freemarker , Whether to enable MVC view resolution for this technology? 默认 true

spring.freemarker.enabled: true

设定模板的前缀, 默认值是 空白

spring.freemarker.prefix:

设定模板的后缀, 默认值是 .ftlh

spring.freemarker.suffix:

Content-Type value.

默认值为 text/html

#spring.freemarker.content-type: text/html

当值不为 text/html时, 浏览器无法直接访问, 会显示404, 但同源ajax可以

#spring.freemarker.content-type: text/plain
#spring.freemarker.content-type: text/JavaScript

模板编码。 默认是 UTF-8

spring.freemarker.charset: UTF-8

设定模板的加载路径,多个以逗号分隔,默认: [classpath:/templates/]

spring.freemarker.template-loader-path: classpath:/templates/

是否检查模板位置是否存在。 默认是 true;

spring.freemarker.check-template-location: false

是否启用模板缓存。 默认 false

spring.freemarker.cache: false

是否优先从文件系统加载模板,以支持热加载,默认为false

spring.freemarker.prefer-file-system-access: true

是否允许HttpServletRequest属性覆盖(隐藏)控制器生成的同名模型属性。 默认 false

spring.freemarker.allow-request-override: false

是否允许HttpSession属性覆盖(隐藏)控制器生成的同名模型属性。 默认false

spring.freemarker.allow-session-override: false

设定所有request的属性在merge到模板的时候,是否要都添加到model中. 默认false

spring.freemarker.expose-request-attributes: false

是否在merge模板的时候,将HttpSession属性都添加到model中, 默认false

spring.freemarker.expose-session-attributes: false

设定是否以springMacroRequestContext的形式暴露RequestContext给Spring’s macro library使用, 默认true

spring.freemarker.expose-spring-macro-helpers: true

views的白名单

可以解析view的清单(白名单) 默认不存在, 空白会阻止所有view , 开头有没有斜杠"/"必须和Controller的返回完全匹配

spring.freemarker.view-names: 后面空白会阻止所有view, 一般可以去掉或注释掉, 下面是一些用法例子 可以用数组,也可以不用

#spring.freemarker.view-names: txt/txt.txt
#spring.freemarker.view-names: txt/txt.txt , txt/txt2.txt, ‘ftl/ftl.ftl’, “ftlh/ftlh.ftlh”
#spring.freemarker.view-names: [txt/txt.txt , txt/txt2.txt, ftl/ftl.ftl, ftlh/ftlh.ftlh]
#spring.freemarker.view-names: [‘txt/txt.txt’ , “txt/txt2.txt”, ftl/ftl.ftl, ftlh/ftlh.ftlh]
#spring.freemarker.view-names:
– ‘txt/txt.txt’
– “txt/txt2.txt”
– ftl/ftl.ftl
– ftlh/ftlh.ftlh
– 可以加单双引号/也可以不加

设定FreeMarker keys.

spring.freemarker.settings.template_update_delay: 0
spring.freemarker.settings.default_encoding: UTF-8
spring.freemarker.settings.classic_compatible: true

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kfepiza

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值