springboot Templating Properties 模板引擎配置属性 2306

springboot Templating Properties 模板引擎配置属性 2306

Springboot Properties 2306

10. Templating Properties 模板属性

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.

spring.groovy.template.allow-request-override

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

false

spring.groovy.template.allow-session-override

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

false

spring.groovy.template.cache

Whether to enable template caching.

false

spring.groovy.template.charset

Template encoding.

UTF-8

spring.groovy.template.check-template-location

Whether to check that the templates location exists.

true

spring.groovy.template.configuration.auto-escape
spring.groovy.template.configuration.auto-indent
spring.groovy.template.configuration.auto-indent-string
spring.groovy.template.configuration.auto-new-line
spring.groovy.template.configuration.base-template-class
spring.groovy.template.configuration.cache-templates
spring.groovy.template.configuration.declaration-encoding
spring.groovy.template.configuration.expand-empty-elements
spring.groovy.template.configuration.locale
spring.groovy.template.configuration.new-line-string
spring.groovy.template.configuration.resource-loader-path
spring.groovy.template.configuration.use-double-quotes

See GroovyMarkupConfigurer

spring.groovy.template.content-type

Content-Type value.

text/html

spring.groovy.template.enabled

Whether to enable MVC view resolution for this technology.

true

spring.groovy.template.expose-request-attributes

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

false

spring.groovy.template.expose-session-attributes

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

false

spring.groovy.template.expose-spring-macro-helpers

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

true

spring.groovy.template.prefix

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

spring.groovy.template.request-context-attribute

Name of the RequestContext attribute for all views.

spring.groovy.template.resource-loader-path

Template path.

classpath:/templates/

spring.groovy.template.suffix

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

.tpl

spring.groovy.template.view-names

View names that can be resolved.

spring.mustache.charset

Template encoding.

UTF-8

spring.mustache.check-template-location

Whether to check that the templates location exists.

true

spring.mustache.enabled

Whether to enable MVC view resolution for Mustache.

true

spring.mustache.prefix

Prefix to apply to template names.

classpath:/templates/

spring.mustache.reactive.media-types

Media types supported by Mustache views.

text/html;charset=UTF-8

spring.mustache.request-context-attribute

Name of the RequestContext attribute for all views.

spring.mustache.servlet.allow-request-override

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

false

spring.mustache.servlet.allow-session-override

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

false

spring.mustache.servlet.cache

Whether to enable template caching.

false

spring.mustache.servlet.content-type

Content-Type value.

spring.mustache.servlet.expose-request-attributes

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

false

spring.mustache.servlet.expose-session-attributes

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

false

spring.mustache.servlet.expose-spring-macro-helpers

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

true

spring.mustache.suffix

Suffix to apply to template names.

.mustache

spring.mustache.view-names

View names that can be resolved.

spring.thymeleaf.cache

Whether to enable template caching.

true

spring.thymeleaf.check-template

Whether to check that the template exists before rendering it.

true

spring.thymeleaf.check-template-location

Whether to check that the templates location exists.

true

spring.thymeleaf.enable-spring-el-compiler

Enable the SpringEL compiler in SpringEL expressions.

false

spring.thymeleaf.enabled

Whether to enable Thymeleaf view resolution for Web frameworks.

true

spring.thymeleaf.encoding

Template files encoding.

UTF-8

spring.thymeleaf.excluded-view-names

Comma-separated list of view names (patterns allowed) that should be excluded from resolution.

spring.thymeleaf.mode

Template mode to be applied to templates. See also Thymeleaf's TemplateMode enum.

HTML

spring.thymeleaf.prefix

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

classpath:/templates/

spring.thymeleaf.reactive.chunked-mode-view-names

Comma-separated list of view names (patterns allowed) that should be the only ones executed in CHUNKED mode when a max chunk size is set.

spring.thymeleaf.reactive.full-mode-view-names

Comma-separated list of view names (patterns allowed) that should be executed in FULL mode even if a max chunk size is set.

spring.thymeleaf.reactive.max-chunk-size

Maximum size of data buffers used for writing to the response. Templates will execute in CHUNKED mode by default if this is set.

0B

spring.thymeleaf.reactive.media-types

Media types supported by the view technology.

[text/html, application/xhtml+xml, application/xml, text/xml, application/rss+xml, application/atom+xml, application/javascript, application/ecmascript, text/javascript, text/ecmascript, application/json, text/css, text/plain, text/event-stream]

spring.thymeleaf.render-hidden-markers-before-checkboxes

Whether hidden form inputs acting as markers for checkboxes should be rendered before the checkbox element itself.

false

spring.thymeleaf.servlet.content-type

Content-Type value written to HTTP responses.

text/html

spring.thymeleaf.servlet.produce-partial-output-while-processing

Whether Thymeleaf should start writing partial output as soon as possible or buffer until template processing is finished.

true

spring.thymeleaf.suffix

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

.html

spring.thymeleaf.template-resolver-order

Order of the template resolver in the chain. By default, the template resolver is first in the chain. Order start at 1 and should only be set if you have defined additional "TemplateResolver" beans.

spring.thymeleaf.view-names

Comma-separated list of view names (patterns allowed) that can be resolved.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: 以下是一篇关于Spring Boot的外文文献,供参考: 标题:Spring Boot: A modern approach to building enterprise Java applications 作者:Phillip Webb 出处:JavaWorld 摘要:Spring Boot是一个新的Java框架,它提供了一种现代化的方式来构建企业级应用程序。Spring Boot通过自动配置和约定大于配置的哲学,使得应用程序的开发和部署变得更加简单和快速。本文将介绍Spring Boot的主要特性,并通过一个简单的实例来演示如何使用Spring Boot构建一个RESTful Web服务。 全文: Introduction Spring Boot is a new framework in the Java ecosystem that provides a modern approach to building enterprise Java applications. It is designed to simplify the development and deployment of Spring-based applications, and to remove the boilerplate code and configuration that can make Java development a tedious and time-consuming process. Spring Boot achieves this by following a philosophy of "convention over configuration", which means that it provides sensible defaults and automatic configuration whenever possible, and allows developers to focus on writing business logic rather than plumbing code. In this article, we will explore the main features of Spring Boot and demonstrate how to build a RESTful web service using Spring Boot. Getting Started To get started with Spring Boot, you can use the Spring Initializr, which is a web-based tool that generates a skeleton project for your application. The Spring Initializr allows you to specify the dependencies that your application requires, and it generates a project that is pre-configured with those dependencies. For example, if you want to build a web application that uses Spring MVC and Thymeleaf for templating, you can use the Spring Initializr to generate a project that includes those dependencies. The generated project will also contain a main application class that is pre-configured with Spring Boot's auto-configuration. Once you have generated your project, you can import it into your IDE and start writing code. Spring Boot provides a number of annotations that you can use to configure your application, such as @RestController, which is used to annotate classes that handle HTTP requests, and @SpringBootApplication, which is used to annotate the main application class. RESTful Web Services One of the most common use cases for Spring Boot is building RESTful web services. Spring Boot provides a number of features that make it easy to build and test RESTful APIs, such as Spring MVC for handling HTTP requests, and Spring Data for accessing databases. To demonstrate how to build a RESTful web service using Spring Boot, let's create a simple application that exposes a REST API for creating and retrieving user accounts. First, we need to create a domain model for our user accounts. We can do this by creating a User class that contains the user's name, email address, and password: ``` public class User { private String name; private String email; private String password; public User(String name, String email, String password) { this.name = name; this.email = email; this.password = password; } public String getName() { return name; } public String getEmail() { return email; } public String getPassword() { return password; } } ``` Next, we need to create a controller class that handles HTTP requests for creating and retrieving user accounts. We can do this by creating a UserController class that is annotated with @RestController: ``` @RestController public class UserController { private List<User> users = new ArrayList<>(); @PostMapping("/users") public void createUser(@RequestBody User user) { users.add(user); } @GetMapping("/users") public List<User> getUsers() { return users; } } ``` The createUser() method handles HTTP POST requests for creating user accounts, and the getUsers() method handles HTTP GET requests for retrieving all user accounts. Finally, we need to configure our application to run as a web server, and to use Spring Boot's auto-configuration to set up our REST API. We can do this by adding the following code to our main application class: ``` @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` This code tells Spring Boot to scan our application for components that are annotated with @RestController, and to create a web server that listens for HTTP requests on port 8080. Conclusion Spring Boot is a powerful framework for building enterprise Java applications. It provides a modern approach to development that simplifies the process of building, testing, and deploying applications. By following a philosophy of "convention over configuration", Spring Boot minimizes the amount of boilerplate code and configuration that developers need to write, and allows them to focus on writing business logic. If you are looking for a new way to build enterprise Java applications, Spring Boot is definitely worth checking out. ### 回答2: Spring Boot是一种用于构建基于Java的企业级应用程序的开源框架。它简化了传统Java开发的繁琐过程,提供了一种快速和方便的方式来创建独立的、可执行的、可部署的应用程序。 近年来,越来越多的开发者开始使用Spring Boot来构建他们的应用程序。这是因为Spring Boot提供了许多有益的特性,例如自动配置、内嵌服务器、依赖管理和监控等。这些功能使得开发者能够更加专注于业务逻辑,而不需要处理复杂的配置和集成问题。 除了这些特性之外,还有一些关于Spring Boot的外文文献可以作为参考。一篇名为"Getting Started with Spring Boot"的文献介绍了如何使用Spring Boot来开发一个简单的Web应用程序。它深入探讨了Spring Boot的核心概念、配置方式以及如何集成其他技术栈。 另一篇名为"Mastering Spring Boot"的文献则更加深入地介绍了Spring Boot的各种高级功能和最佳实践。它涵盖了Spring Boot的原理、自定义配置、安全性和性能优化等方面。这篇文献对于那些希望更加深入了解Spring Boot并且在实践中获得最佳结果的开发者来说是非常有用的。 总体而言,Spring Boot的外文文献提供了丰富的资源,可以帮助开发者更好地了解和使用这个强大的框架。无论是初学者还是有经验的开发者,阅读这些文献将对他们在Spring Boot开发中产生积极的影响。 ### 回答3: Spring Boot是一种基于Java的开源框架,用于快速开发和构建独立的,可部署的,生产级的应用程序。它提供了一个简化的开发过程,使开发人员能够更专注于业务逻辑而不是底层的配置Spring Boot被广泛认可,并在许多外文文献中得到了深入研究和讨论。以下是一些关于Spring Boot的外文文献的主要内容和观点: 1. "Spring Boot - A new paradigm for developing Spring applications" by Phil Webb et al. (2014) 该文献介绍了Spring Boot的基本思想和设计理念,指出它的出现是为了简化Spring应用程序的开发过程,并提供了一种新的范式。它解释了Spring Boot的核心功能和特点,并提供了示例代码来说明如何使用Spring Boot构建应用程序。 2. "Building Microservices with Spring Boot and Spring Cloud" by Josh Long and Kenny Bastani (2017) 这本书详细介绍了使用Spring BootSpring Cloud构建微服务架构的方法和实践。它涵盖了微服务体系结构的基本概念,解释了Spring BootSpring Cloud如何在这种架构中发挥作用,并提供了许多示例和最佳实践。 3. "Spring Boot in Action" by Craig Walls (2016) 该书深入介绍了Spring Boot的各个方面,包括自动配置,部署和监控,测试和部署等。它提供了丰富的示例和实践,帮助读者理解和使用Spring Boot的各种功能和特性。 4. "Spring Boot and Hibernate" by Amritendu De (2018) 该文献探讨了Spring Boot和Hibernate之间的集成和协作。它详细介绍了如何使用Spring Boot和Hibernate构建数据访问层,并提供了一些最佳实践和示例代码来帮助开发人员理解和使用这两个框架的集成。 总之,Spring Boot在外文文献中得到了广泛的研究和探讨。这些文献提供了关于Spring Boot的详细介绍、最佳实践以及与其他相关技术的集成方法等有价值的信息。通过阅读这些外文文献,开发人员可以更好地理解和使用Spring Boot框架来开发高效且可靠的应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

kfepiza

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

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

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

打赏作者

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

抵扣说明:

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

余额充值