From 23bc7e913d4e1afbda0805eea6371f36cf045b6d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 18 Jun 2016 21:32:28 +0200 Subject: [PATCH] WIP: welcome + error --- .../java/de/juplo/thymeproxy/Application.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/juplo/thymeproxy/Application.java b/src/main/java/de/juplo/thymeproxy/Application.java index 2adafb2..b5a38cd 100644 --- a/src/main/java/de/juplo/thymeproxy/Application.java +++ b/src/main/java/de/juplo/thymeproxy/Application.java @@ -4,7 +4,6 @@ import de.juplo.thymeleaf.JuploDialect; import java.util.HashMap; import java.util.Map; import org.apache.http.impl.client.CloseableHttpClient; -import org.springframework.beans.BeanUtils; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -15,8 +14,8 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter import org.springframework.web.servlet.mvc.UrlFilenameViewController; import org.thymeleaf.resourceresolver.IResourceResolver; import org.thymeleaf.resourceresolver.UrlResourceResolver; +import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.view.ThymeleafView; -import org.thymeleaf.spring4.view.ThymeleafViewResolver; import org.thymeleaf.templateresolver.TemplateResolver; @@ -106,11 +105,9 @@ public class Application extends WebMvcConfigurerAdapter } @Bean - public ThymeleafView error() + public ThymeleafView error(SpringTemplateEngine templateEngine) { - ThymeleafView view = BeanUtils.instantiateClass(ThymeleafView.class); - view.setTemplateName("/thymeleaf/error.html"); - return view; + return new ErrorThymeleafView(templateEngine, "/thymeleaf/error.html"); } @Override @@ -124,4 +121,14 @@ public class Application extends WebMvcConfigurerAdapter { SpringApplication.run(Application.class, args); } + + + static class ErrorThymeleafView extends ThymeleafView + { + ErrorThymeleafView(SpringTemplateEngine templateEngine, String templateName) + { + super(templateName); + setTemplateEngine(templateEngine); + } + } } \ No newline at end of file -- 2.20.1