From: Kai Moritz Date: Sat, 18 Jun 2016 19:32:28 +0000 (+0200) Subject: WIP: welcome + error X-Git-Tag: alt~19 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=23bc7e913d4e1afbda0805eea6371f36cf045b6d;p=maven-thymeleaf-skin WIP: welcome + error --- 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