<!-- application-settings -->
<thymeproxy.name>${project.name}</thymeproxy.name>
- <thymeproxy.origin>http://localhost:8080/</thymeproxy.origin>
+ <thymeproxy.origin>http://localhost:8080</thymeproxy.origin>
<thymeproxy.port>8888</thymeproxy.port>
<thymeproxy.ttl>300000</thymeproxy.ttl><!-- 5 minutes -->
+ <thymeproxy.cacheable>true</thymeproxy.cacheable>
<httpclient.logging.level>ERROR</httpclient.logging.level>
<!-- used versions (not defined in spring-boot) -->
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
+import org.springframework.web.servlet.mvc.UrlFilenameViewController;
+import org.thymeleaf.resourceresolver.IResourceResolver;
+import org.thymeleaf.resourceresolver.UrlResourceResolver;
+import org.thymeleaf.templateresolver.TemplateResolver;
@SpringBootApplication
{
@Bean
public RegexUrlHandlerMapping proxiedHandlerMapping(
- ProxyHttpRequestHandler handler
+ ProxyHttpRequestHandler proxy,
+ UrlFilenameViewController views
)
{
RegexUrlHandlerMapping mapping = new RegexUrlHandlerMapping();
mapping.setOrder(Ordered.HIGHEST_PRECEDENCE);
Map<String, Object> mappings = new HashMap<>();
- mappings.put(".*\\.html$", handler);
- mappings.put("/css/.+", handler);
- mappings.put("/js/.+", handler);
- mappings.put("/fonts/.+", handler);
- mappings.put("/.+/", handler);
+ mappings.put("/thymeleaf/.*\\.html", proxy);
+ mappings.put("/css/.+", proxy);
+ mappings.put("/js/.+", proxy);
+ mappings.put("/fonts/.+", proxy);
+ mappings.put(".*\\.html", views);
mapping.setUrlMap(mappings);
return mapping;
}
@Bean
- public ProxyHttpRequestHandler proxiedRequestHandler(
+ public ProxyHttpRequestHandler proxyHttpRequestHandler(
CloseableHttpClient client,
Environment env
)
return handler;
}
+ @Bean
+ public UrlFilenameViewController urlFilenameViewController()
+ {
+ return new UrlFilenameViewController();
+ }
+
+ @Bean
+ public TemplateResolver defaultTemplateResolver(
+ IResourceResolver resources,
+ Environment env
+ )
+ {
+ TemplateResolver resolver = new TemplateResolver();
+ resolver.setResourceResolver(resources);
+ resolver.setPrefix("//thymeleaf/");
+ resolver.setSuffix(".html");
+ resolver.setTemplateMode("HTML5");
+ resolver.setCharacterEncoding("UTF-8");
+ resolver.setCacheable(Boolean.valueOf(env.getProperty("thymeproxy.cacheable")));
+ return resolver;
+ }
+
+ @Bean
+ public UrlResourceResolver thymeleafResourceResolver()
+ {
+ return new UrlResourceResolver();
+ }
+
public static void main(String[] args)
{