|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2014 the original author or authors.
|
|
|
|
|
* Copyright 2012-2015 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -38,7 +38,6 @@ import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
|
import org.springframework.core.Ordered;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.web.servlet.view.UrlBasedViewResolver;
|
|
|
|
|
import org.springframework.web.servlet.view.groovy.GroovyMarkupConfig;
|
|
|
|
@ -79,7 +78,7 @@ public class GroovyTemplateAutoConfiguration {
|
|
|
|
|
public void checkTemplateLocationExists() {
|
|
|
|
|
if (this.properties.isCheckTemplateLocation() && !isUsingGroovyAllJar()) {
|
|
|
|
|
TemplateLocation location = new TemplateLocation(
|
|
|
|
|
this.properties.getPrefix());
|
|
|
|
|
this.properties.getResourceLoaderPath());
|
|
|
|
|
Assert.state(location.exists(this.applicationContext),
|
|
|
|
|
"Cannot find template location: " + location
|
|
|
|
|
+ " (please add some templates, check your Groovy "
|
|
|
|
@ -115,7 +114,7 @@ public class GroovyTemplateAutoConfiguration {
|
|
|
|
|
@ConfigurationProperties(prefix = "spring.groovy.template.configuration")
|
|
|
|
|
public GroovyMarkupConfigurer groovyMarkupConfigurer() {
|
|
|
|
|
GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer();
|
|
|
|
|
configurer.setResourceLoaderPath(this.properties.getPrefix());
|
|
|
|
|
configurer.setResourceLoaderPath(this.properties.getResourceLoaderPath());
|
|
|
|
|
configurer.setCacheTemplates(this.properties.isCache());
|
|
|
|
|
if (this.templateEngine != null) {
|
|
|
|
|
configurer.setTemplateEngine(this.templateEngine);
|
|
|
|
@ -139,21 +138,10 @@ public class GroovyTemplateAutoConfiguration {
|
|
|
|
|
@ConditionalOnMissingBean(name = "groovyMarkupViewResolver")
|
|
|
|
|
public GroovyMarkupViewResolver groovyMarkupViewResolver() {
|
|
|
|
|
GroovyMarkupViewResolver resolver = new GroovyMarkupViewResolver();
|
|
|
|
|
configureViewResolver(resolver);
|
|
|
|
|
this.properties.applyToViewResolver(resolver);
|
|
|
|
|
return resolver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void configureViewResolver(UrlBasedViewResolver resolver) {
|
|
|
|
|
resolver.setSuffix(this.properties.getSuffix());
|
|
|
|
|
resolver.setCache(this.properties.isCache());
|
|
|
|
|
resolver.setContentType(this.properties.getContentType());
|
|
|
|
|
resolver.setViewNames(this.properties.getViewNames());
|
|
|
|
|
resolver.setRequestContextAttribute("spring");
|
|
|
|
|
// This resolver acts as a fallback resolver (e.g. like a
|
|
|
|
|
// InternalResourceViewResolver) so it needs to have low precedence
|
|
|
|
|
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|