From 35c92348ae0a1d842dda7b01f4023651642e3a2f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 19 Aug 2015 14:32:31 +0200 Subject: [PATCH] Document Velocity view resolver customization Changing the velocity view resolver to a VelocityLayoutViewResolver seems a common use case so it has now a dedicated section in the relevant how to. Closes gh-3732 --- spring-boot-docs/src/main/asciidoc/howto.adoc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index b9558f0fbd..10b03d2933 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -1130,6 +1130,28 @@ Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`W {sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] +[[howto-customize-view-resolvers-velocity]] +=== Velocity + +By default, Spring Boot configures a `VelocityViewResolver`. If you need a `VelocityLayoutViewResolver` +instead, you can easily configure your own by creating a bean with name `velocityViewResolver`. You can +also inject the `VelocityProperties` instance to apply the base defaults to your custom view resolver. + +The following example replaces the auto-configured velocity view resolver with a +`VelocityLayoutViewResolver` defining a customized `layoutUrl` and all settings that would have been +applied from the auto-configuration: + +[source,java,indent=0,subs="verbatim,quotes,attributes"] +---- + @Bean(name = "velocityViewResolver") + public VelocityLayoutViewResolver velocityViewResolver(VelocityProperties properties) { + VelocityLayoutViewResolver resolver = new VelocityLayoutViewResolver(); + properties.applyToViewResolver(resolver); + resolver.setLayoutUrl("layout/default.vm"); + return resolver; + } +---- + [[howto-logging]] == Logging