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
pull/3785/merge
Stephane Nicoll 9 years ago
parent 3c91781bee
commit 35c92348ae

@ -1130,6 +1130,28 @@ Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`W
{sc-spring-boot-autoconfigure}/velocity/VelocityAutoConfiguration.{sc-ext}[`VelocityAutoConfiguration`] {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]] [[howto-logging]]
== Logging == Logging

Loading…
Cancel
Save