--- /dev/null
+package de.juplo.branding.web;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.tiles.servlet.context.ServletUtil;
+
+
+
+/**
+ * Fixes a logic-bug in the colaboration of Thymeleaf and Tiles.
+ *
+ * Tiles 2.2.x tries to use RequestDispatcher.forward() whenever possible, but
+ * this breaks Thymeleaf, because the original response is marked as committed,
+ * when forwarding. Hence, Thymeleaf cannot render its result in the response
+ * and an empty page is returned.
+ *
+ * @author kai
+ */
+public class ForceIncludeFilter implements Filter
+{
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ }
+
+ @Override
+ public void doFilter(
+ ServletRequest request,
+ ServletResponse response,
+ FilterChain chain
+ )
+ throws
+ IOException,
+ ServletException
+ {
+ if ((response instanceof HttpServletResponse))
+ ServletUtil.setForceInclude((HttpServletRequest)request, true);
+
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+}
<!-- UTF-8 -->
+
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
</filter-mapping>
+ <!-- Fix a logic-bug in the colaboration of Thymeleaf and Tiles -->
+
+ <filter>
+ <filter-name>forceIncludeFilter</filter-name>
+ <filter-class>de.juplo.branding.web.ForceIncludeFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>forceIncludeFilter</filter-name>
+ <url-pattern>*.html</url-pattern>
+ </filter-mapping>
+
+
<!-- Handles all requests into the application -->
<servlet>