diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/AbstractFreeMarkerConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/AbstractFreeMarkerConfiguration.java index 832d6cd681..2aa3672f22 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/AbstractFreeMarkerConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/AbstractFreeMarkerConfiguration.java @@ -42,6 +42,7 @@ abstract class AbstractFreeMarkerConfiguration { factory.setPreferFileSystemAccess(this.properties.isPreferFileSystemAccess()); factory.setDefaultEncoding(this.properties.getCharsetName()); Properties settings = new Properties(); + settings.put("recognize_standard_file_extensions", "true"); settings.putAll(this.properties.getSettings()); factory.setFreemarkerSettings(settings); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java index 347e827b05..be5e7eb62a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerProperties.java @@ -36,7 +36,7 @@ public class FreeMarkerProperties extends AbstractTemplateViewResolverProperties public static final String DEFAULT_PREFIX = ""; - public static final String DEFAULT_SUFFIX = ".ftl"; + public static final String DEFAULT_SUFFIX = ".ftlh"; /** * Well-known FreeMarker keys which are passed to FreeMarker's Configuration. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 4f5d6cfc14..8eda844d5b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -495,7 +495,7 @@ }, { "name": "spring.freemarker.suffix", - "defaultValue": ".ftl" + "defaultValue": ".ftlh" }, { "name": "spring.groovy.template.prefix", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java index baee19357f..108ad43859 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationReactiveIntegrationTests.java @@ -108,7 +108,7 @@ class FreeMarkerAutoConfigurationReactiveIntegrationTests { this.contextRunner.withPropertyValues().run((context) -> { FreeMarkerConfigurer freemarker = context.getBean(FreeMarkerConfigurer.class); StringWriter writer = new StringWriter(); - freemarker.getConfiguration().getTemplate("message.ftl").process(new DataModel(), writer); + freemarker.getConfiguration().getTemplate("message.ftlh").process(new DataModel(), writer); assertThat(writer.toString()).contains("Hello World"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java index d01be80b23..11418739de 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java @@ -143,7 +143,7 @@ class FreeMarkerAutoConfigurationServletIntegrationTests { load(); FreeMarkerConfigurer freemarker = this.context.getBean(FreeMarkerConfigurer.class); StringWriter writer = new StringWriter(); - freemarker.getConfiguration().getTemplate("message.ftl").process(new DataModel(), writer); + freemarker.getConfiguration().getTemplate("message.ftlh").process(new DataModel(), writer); assertThat(writer.toString()).contains("Hello World"); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java index 993b6edbd2..470a5725a0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java @@ -49,7 +49,7 @@ public class FreeMarkerAutoConfigurationTests { this.contextRunner.run((context) -> { freemarker.template.Configuration freemarker = context.getBean(freemarker.template.Configuration.class); StringWriter writer = new StringWriter(); - freemarker.getTemplate("message.ftl").process(new DataModel(), writer); + freemarker.getTemplate("message.ftlh").process(new DataModel(), writer); assertThat(writer.toString()).contains("Hello World"); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftlh similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftl rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/custom-templates/custom.ftlh diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftlh similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftl rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/error/507.ftlh diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftlh similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftl rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/home.ftlh diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftlh similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftl rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/message.ftlh diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftl b/spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftlh similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftl rename to spring-boot-project/spring-boot-autoconfigure/src/test/resources/templates/prefix/prefixed.ftlh diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index f3e9fce9d3..addc901e54 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1417,7 +1417,7 @@ externalized to `spring.freemarker.templateLoaderPath` and has a default value o '`classpath:/templates/`') by surrounding the view name with a prefix and a suffix. The prefix is externalized to `spring.freemarker.prefix`, and the suffix is externalized to `spring.freemarker.suffix`. The default values of the prefix and suffix are empty and -'`.ftl`', respectively. You can override `FreeMarkerViewResolver` by providing a bean +'`.ftlh`', respectively. You can override `FreeMarkerViewResolver` by providing a bean of the same name. * If you use Groovy templates (actually, if `groovy-templates` is on your classpath), you also have a `GroovyMarkupViewResolver` named '`groovyMarkupViewResolver`'. It looks for @@ -2522,7 +2522,7 @@ error page rather than disabling it completely. Overriding the error page with your own depends on the templating technology that you use. For example, if you use Thymeleaf, you can add an `error.html` template. -If you use FreeMarker, you can add an `error.ftl` template. In general, you +If you use FreeMarker, you can add an `error.ftlh` template. In general, you need a `View` that resolves with a name of `error` or a `@Controller` that handles the `/error` path. Unless you replaced some of the default configuration, you should find a `BeanNameViewResolver` in your `ApplicationContext`, so a `@Bean` named `error` would diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 459376c8a5..b5490e5e02 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -2702,7 +2702,7 @@ follows: +- resources/ +- templates/ +- error/ - | +- 5xx.ftl + | +- 5xx.ftlh +- ---- diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/error.ftl b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/error.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/error.ftl rename to spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/error.ftlh diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/home.ftl b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/home.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/home.ftl rename to spring-boot-samples/spring-boot-sample-actuator-custom-security/src/main/resources/templates/home.ftlh diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.ftl b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.ftl rename to spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/error.ftlh diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.ftl b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.ftl rename to spring-boot-samples/spring-boot-sample-actuator-ui/src/main/resources/templates/home.ftlh diff --git a/spring-boot-samples/spring-boot-sample-jpa/src/main/resources/templates/index.ftl b/spring-boot-samples/spring-boot-sample-jpa/src/main/resources/templates/index.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-jpa/src/main/resources/templates/index.ftl rename to spring-boot-samples/spring-boot-sample-jpa/src/main/resources/templates/index.ftlh diff --git a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/error.ftl b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/error.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/error.ftl rename to spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/error.ftlh diff --git a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/welcome.ftl b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/welcome.ftlh similarity index 100% rename from spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/welcome.ftl rename to spring-boot-samples/spring-boot-sample-web-freemarker/src/main/resources/templates/welcome.ftlh