WIP: welcome + error
authorKai Moritz <kai@juplo.de>
Sat, 18 Jun 2016 19:32:28 +0000 (21:32 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 18 Jun 2016 19:32:28 +0000 (21:32 +0200)
src/main/java/de/juplo/thymeproxy/Application.java

index 2adafb2..b5a38cd 100644 (file)
@@ -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