浏览代码

Update to Thymeleaf 3.0.2 and remove tiles

Spring 5 removed support for Tiles 2 and Thymeleaf does not support
Tiles 3 yet. This commit updates to Thymeleaf 3.0.2 and uses
Thymeleaf's build in layout support.

Issue gh-4080
Rob Winch 8 年之前
父节点
当前提交
5e35e37a2b
共有 24 个文件被更改,包括 180 次插入362 次删除
  1. 5 5
      docs/guides/src/docs/asciidoc/form-javaconfig.asc
  2. 1 1
      gradle/javaprojects.gradle
  3. 0 7
      samples/javaconfig/chat/src/main/java/sample/config/WebMvcConfiguration.java
  4. 0 57
      samples/javaconfig/chat/src/main/resources/tiles/tiles-def.xml
  5. 5 6
      samples/javaconfig/chat/src/main/resources/views/chat.html
  6. 5 6
      samples/javaconfig/chat/src/main/resources/views/layout.html
  7. 23 26
      samples/javaconfig/chat/src/main/resources/views/login.html
  8. 1 1
      samples/javaconfig/form/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy
  9. 1 1
      samples/javaconfig/form/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy
  10. 23 26
      samples/javaconfig/form/src/main/resources/views/login.html
  11. 0 41
      samples/javaconfig/hellojs/src/main/java/org/springframework/security/samples/mvc/config/CustomMvcConfig.java
  12. 1 1
      samples/javaconfig/jdbc/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy
  13. 1 1
      samples/javaconfig/ldap/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy
  14. 7 8
      samples/javaconfig/messages/build.gradle
  15. 27 31
      samples/javaconfig/messages/src/main/java/org/springframework/security/samples/mvc/config/WebMvcConfiguration.java
  16. 0 57
      samples/javaconfig/messages/src/main/resources/tiles/tiles-def.xml
  17. 6 7
      samples/javaconfig/messages/src/main/resources/views/layout.html
  18. 5 5
      samples/javaconfig/messages/src/main/resources/views/messages/compose.html
  19. 5 5
      samples/javaconfig/messages/src/main/resources/views/messages/inbox.html
  20. 5 5
      samples/javaconfig/messages/src/main/resources/views/messages/show.html
  21. 6 6
      samples/javaconfig/openid/src/main/resources/views/login.html
  22. 5 5
      samples/javaconfig/openid/src/main/resources/views/user/show.html
  23. 23 26
      samples/javaconfig/preauth/src/main/resources/views/login.html
  24. 25 28
      samples/javaconfig/rememberme/src/main/resources/views/login.html

+ 5 - 5
docs/guides/src/docs/asciidoc/form-javaconfig.asc

@@ -162,12 +162,12 @@ Our existing configuration means that all we need to do is create a *login.html*
 .src/main/resources/views/login.html
 [source,xml]
 ----
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Create</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{})">
+    <title>Please Login</title>
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+    <div th:fragment="content">
         <form name="f" th:action="@{/login}" method="post">               <1>
             <fieldset>
                 <legend>Please Login</legend>

+ 1 - 1
gradle/javaprojects.gradle

@@ -37,7 +37,7 @@ ext.springDataJpaVersion = '1.10.2.RELEASE'
 ext.springDataRedisVersion = '1.7.2.RELEASE'
 ext.springSessionVersion = '1.2.1.RELEASE'
 ext.springBootVersion = '1.4.0.RELEASE'
-ext.thymeleafVersion = '2.1.5.RELEASE'
+ext.thymeleafVersion = '3.0.2.RELEASE'
 ext.jsonassertVersion = '1.3.0'
 ext.validationApiVersion = '1.1.0.Final'
 

+ 0 - 7
samples/javaconfig/chat/src/main/java/sample/config/WebMvcConfiguration.java

@@ -64,13 +64,6 @@ public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
 		return result;
 	}
 
-	@Bean
-	public ThymeleafTilesConfigurer tilesConfigurer() {
-		ThymeleafTilesConfigurer tilesConfigurer = new ThymeleafTilesConfigurer();
-		tilesConfigurer.setDefinitions(new String[] { "classpath:tiles/tiles-def.xml" });
-		return tilesConfigurer;
-	}
-
 	@Bean
 	public SpringTemplateEngine templateEngine(
 			ClassLoaderTemplateResolver templateResolver) {

+ 0 - 57
samples/javaconfig/chat/src/main/resources/tiles/tiles-def.xml

@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE tiles-definitions PUBLIC
-	   "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
-	   "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
-<tiles-definitions>
-
-  <definition name="messages/*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/messages/{1}"/>
-	<put-attribute name="title"
-		value="title/messages/{1}"/>
-	<put-attribute name="head"
-		value="head/messages/{1}"/>
-  </definition>
-
-  <definition name="content/messages/*"
-	  template="messages/{1} :: content"/>
-  <definition name="title/messages/*"
-	  template="messages/{1} :: title"/>
-  <definition name="head/messages/*"
-	  template="messages/{1} :: /html/head/link"/>
-
-  <definition name="user/*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/user/{1}"/>
-	<put-attribute name="title"
-		value="title/user/{1}"/>
-	<put-attribute name="head"
-		value="head/user/{1}"/>
-  </definition>
-
-  <definition name="content/user/*"
-	  template="user/{1} :: content"/>
-  <definition name="title/user/*"
-	  template="user/{1} :: title"/>
-  <definition name="head/user/*"
-	  template="user/{1} :: /html/head/link"/>
-
-  <definition name="*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/{1}"/>
-	<put-attribute name="title"
-		value="title/{1}"/>
-	<put-attribute name="head"
-		value="head/{1}"/>
-  </definition>
-
-  <definition name="content/*"
-	  template="{1} :: content"/>
-  <definition name="title/*"
-	  template="{1} :: title"/>
-  <definition name="head/*"
-	  template="{1} :: /html/head/link"/>
-</tiles-definitions>

+ 5 - 6
samples/javaconfig/chat/src/main/resources/views/chat.html

@@ -1,9 +1,8 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Chat</title>
-  </head>
-  <body>
-    <div tiles:fragment="content">
+<html xmlns:th="http://www.thymeleaf.org">
+    <head th:include="layout :: head(title=~{::title},links=~{})">
+      <title>Chat</title>
+    </head>
+    <body th:include="layout :: body" th:with="content=~{::content}">
         <div class="container">
           <div id="heading" class="masthead">
             <h3 class="muted">Chat Application</h3>

+ 5 - 6
samples/javaconfig/chat/src/main/resources/views/layout.html

@@ -1,9 +1,8 @@
 <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:th="http://www.thymeleaf.org"
-      xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:include="title">SecureMail:</title>
+      xmlns:th="http://www.thymeleaf.org">
+  <head th:fragment="head(title,links)">
+    <title>SecureMail: <th:block th:include="${title}"></th:block></title>
     <link rel="icon" type="image/x-icon" th:href="@{/resources/img/favicon.ico}" href="../resources/img/favicon.ico"/>
     <link th:href="@{/resources/css/bootstrap.css}" href="../resources/css/bootstrap.css" rel="stylesheet"></link>
     <style type="text/css">
@@ -77,7 +76,7 @@
     <!--[if lt IE 9]>
       <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
-    <script tiles:replace="head"></script>
+     <th:block th:replace="${links}"/>
   </head>
 
 
@@ -111,7 +110,7 @@
               th:text="${globalMessage}">
             Some Success message
         </div>
-        <div tiles:substituteby="content">
+         <div th:replace="${content}">
             Fake content
         </div>
       </div>

+ 23 - 26
samples/javaconfig/chat/src/main/resources/views/login.html

@@ -1,27 +1,24 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Log In</title>
-  </head>
-  <body>
-    <div tiles:fragment="content">
-        <form name="f" th:action="@{/login}" method="post">
-	        <fieldset>
-	            <legend>Please Login</legend>
-                <div th:if="${param.error}" class="alert alert-error">
-                    Invalid username and password.
-                </div>
-                <div th:if="${param.logout}" class="alert alert-success">
-                    You have been logged out.
-                </div>
-	            <label for="username">Username</label>
-	            <input type="text" id="username" name="username"/>
-	            <label for="password">Password</label>
-	            <input type="password" id="password" name="password"/>
-	            <div class="form-actions">
-	                <button type="submit" class="btn">Log in</button>
-	            </div>
-	        </fieldset>
-	    </form>
-    </div>
-  </body>
+<html xmlns:th="http://www.thymeleaf.org">
+	<head th:include="layout :: head(title=~{::title},links=~{})">
+		<title>Please Login</title>
+	</head>
+	<body th:include="layout :: body" th:with="content=~{::content}">
+		<div th:fragment="content">
+			<form name="f" th:action="@{/login}" method="post">
+				<fieldset>
+					<legend>Please Login</legend>
+					<div th:if="${param.error}" class="alert alert-error">Invalid
+						username and password.</div>
+					<div th:if="${param.logout}" class="alert alert-success">You
+						have been logged out.</div>
+					<label for="username">Username</label> <input type="text"
+						id="username" name="username" /> <label for="password">Password</label>
+					<input type="password" id="password" name="password" />
+					<div class="form-actions">
+						<button type="submit" class="btn">Log in</button>
+					</div>
+				</fieldset>
+			</form>
+		</div>
+	</body>
 </html>

+ 1 - 1
samples/javaconfig/form/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy

@@ -24,7 +24,7 @@ import geb.*
  */
 class HomePage extends Page {
 	static url = ''
-	static at = { assert driver.title == 'Messages : View All'; true}
+	static at = { assert driver.title == 'SecureMail: View All'; true}
 	static content = {
 		user { $('p.navbar-text').text() }
 		logout { $('input', type: 'submit').click() }

+ 1 - 1
samples/javaconfig/form/src/integration-test/groovy/org/springframework/security/samples/pages/LoginPage.groovy

@@ -24,7 +24,7 @@ import geb.*
  */
 class LoginPage extends Page {
 	static url = 'login'
-	static at = { assert driver.title == 'Please Login'; true}
+	static at = { assert driver.title == 'SecureMail: Please Login'; true}
 	static content = {
 		login(required:false) { user='user', password='password' ->
 			loginForm.username = user

+ 23 - 26
samples/javaconfig/form/src/main/resources/views/login.html

@@ -1,27 +1,24 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Please Login</title>
-  </head>
-  <body>
-    <div tiles:fragment="content">
-        <form name="f" th:action="@{/login}" method="post">
-	        <fieldset>
-	            <legend>Please Login</legend>
-                <div th:if="${param.error}" class="alert alert-error">
-                    Invalid username and password.
-                </div>
-                <div th:if="${param.logout}" class="alert alert-success">
-                    You have been logged out.
-                </div>
-	            <label for="username">Username</label>
-	            <input type="text" id="username" name="username"/>
-	            <label for="password">Password</label>
-	            <input type="password" id="password" name="password"/>
-	            <div class="form-actions">
-	                <button type="submit" class="btn">Log in</button>
-	            </div>
-	        </fieldset>
-	    </form>
-    </div>
-  </body>
+<html xmlns:th="http://www.thymeleaf.org">
+	<head th:include="layout :: head(title=~{::title},links=~{})">
+		<title>Please Login</title>
+	</head>
+	<body th:include="layout :: body" th:with="content=~{::content}">
+		<div th:fragment="content">
+			<form name="f" th:action="@{/login}" method="post">
+				<fieldset>
+					<legend>Please Login</legend>
+					<div th:if="${param.error}" class="alert alert-error">Invalid
+						username and password.</div>
+					<div th:if="${param.logout}" class="alert alert-success">You
+						have been logged out.</div>
+					<label for="username">Username</label> <input type="text"
+						id="username" name="username" /> <label for="password">Password</label>
+					<input type="password" id="password" name="password" />
+					<div class="form-actions">
+						<button type="submit" class="btn">Log in</button>
+					</div>
+				</fieldset>
+			</form>
+		</div>
+	</body>
 </html>

+ 0 - 41
samples/javaconfig/hellojs/src/main/java/org/springframework/security/samples/mvc/config/CustomMvcConfig.java

@@ -1,41 +0,0 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.security.samples.mvc.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.thymeleaf.spring4.SpringTemplateEngine;
-import org.thymeleaf.spring4.view.ThymeleafViewResolver;
-
-/**
- * Disable tiles so that we can provide our custom view without being decorated.
- *
- * @author Rob Winch
- *
- */
-@Configuration
-public class CustomMvcConfig {
-
-	@Bean
-	public ThymeleafViewResolver thymeleafViewResolver(SpringTemplateEngine templateEngine) {
-		ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
-		viewResolver.setOrder(Ordered.HIGHEST_PRECEDENCE - 10);
-		viewResolver.setTemplateEngine(templateEngine);
-		return viewResolver;
-	}
-
-}

+ 1 - 1
samples/javaconfig/jdbc/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy

@@ -24,7 +24,7 @@ import geb.*
  */
 class HomePage extends Page {
 	static url = ''
-	static at = { assert driver.title == 'Messages : View All'; true}
+	static at = { assert driver.title.endsWith('View All') == true; true}
 	static content = {
 		user { $('p.navbar-text').text() }
 		logout { $('input', type: 'submit').click() }

+ 1 - 1
samples/javaconfig/ldap/src/integration-test/groovy/org/springframework/security/samples/pages/HomePage.groovy

@@ -24,7 +24,7 @@ import geb.*
  */
 class HomePage extends Page {
 	static url = ''
-	static at = { assert driver.title == 'Messages : View All'; true}
+	static at = { assert driver.title == 'SecureMail: View All'; true}
 	static content = {
 		user { $('p.navbar-text').text() }
 		logout { $('input', type: 'submit').click() }

+ 7 - 8
samples/javaconfig/messages/build.gradle

@@ -1,12 +1,10 @@
 sonarqube.skipProject = true
 
 dependencies {
-	provided "javax.servlet:javax.servlet-api:3.0.1"
-
+	provided "javax.servlet:javax.servlet-api:$servletApiVersion"
 
 	compile project(":spring-security-web"),
 			project(":spring-security-config"),
-			"org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final",
 			"org.hsqldb:hsqldb:$hsqlVersion",
 			"javax.validation:validation-api:$validationApiVersion",
 			"org.hibernate:hibernate-validator:$hibernateValidatorVersion",
@@ -20,11 +18,12 @@ dependencies {
 			"org.springframework:spring-core:$springVersion",
 			"org.springframework:spring-aspects:$springVersion",
 			"org.thymeleaf:thymeleaf-spring4:$thymeleafVersion",
-			"org.thymeleaf.extras:thymeleaf-extras-tiles2-spring4:2.1.1.RELEASE"
-	  compile('org.hibernate:hibernate-entitymanager:3.6.10.Final') {
+			"nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.0.4",
+			"org.eclipse.persistence:javax.persistence:$javaPersistenceVersion"
+	compile("org.hibernate:hibernate-entitymanager:$hibernateVersion") {
 			exclude group:'javassist', module: 'javassist'
-	  }
-	  compile("org.springframework.data:spring-data-jpa:$springDataJpaVersion") {
+	}
+	compile("org.springframework.data:spring-data-jpa:$springDataJpaVersion") {
 			exclude group:'org.aspectj', module:'aspectjrt'
-	  }
+	}
 }

+ 27 - 31
samples/javaconfig/messages/src/main/java/org/springframework/security/samples/mvc/config/WebMvcConfiguration.java

@@ -16,26 +16,30 @@
 package org.springframework.security.samples.mvc.config;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.core.Ordered;
 import org.springframework.data.repository.support.DomainClassConverter;
 import org.springframework.format.support.FormattingConversionService;
+import org.springframework.web.servlet.ViewResolver;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
-import org.thymeleaf.extras.tiles2.dialect.TilesDialect;
-import org.thymeleaf.extras.tiles2.spring4.web.configurer.ThymeleafTilesConfigurer;
-import org.thymeleaf.extras.tiles2.spring4.web.view.ThymeleafTilesView;
+import org.thymeleaf.TemplateEngine;
 import org.thymeleaf.spring4.SpringTemplateEngine;
+import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
 import org.thymeleaf.spring4.view.ThymeleafViewResolver;
-import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
+import org.thymeleaf.templatemode.TemplateMode;
 
 @EnableWebMvc
 @ComponentScan("org.springframework.security.samples.mvc")
 public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
 
+	@Autowired
+	private ApplicationContext applicationContext;
+
 	@Autowired
 	private FormattingConversionService mvcConversionService;
 
@@ -47,42 +51,34 @@ public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
 
 	@Override
 	public void addResourceHandlers(ResourceHandlerRegistry registry) {
-		registry.addResourceHandler("/resources/**")
-				.addResourceLocations("classpath:/resources/").setCachePeriod(31556926);
+		registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/resources/")
+				.setCachePeriod(31556926);
 		registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
 	}
 
 	@Bean
-	public ClassLoaderTemplateResolver templateResolver() {
-		ClassLoaderTemplateResolver result = new ClassLoaderTemplateResolver();
-		result.setPrefix("views/");
-		result.setSuffix(".html");
-		result.setTemplateMode("HTML5");
-		return result;
-	}
-
-	@Bean
-	public ThymeleafTilesConfigurer tilesConfigurer() {
-		ThymeleafTilesConfigurer tilesConfigurer = new ThymeleafTilesConfigurer();
-		tilesConfigurer.setDefinitions(new String[] { "classpath:tiles/tiles-def.xml" });
-		return tilesConfigurer;
+	public ViewResolver viewResolver() {
+		ThymeleafViewResolver resolver = new ThymeleafViewResolver();
+		resolver.setTemplateEngine(templateEngine());
+		resolver.setCharacterEncoding("UTF-8");
+		return resolver;
 	}
 
 	@Bean
-	public SpringTemplateEngine templateEngine(
-			ClassLoaderTemplateResolver templateResolver) {
-		SpringTemplateEngine templateEngine = new SpringTemplateEngine();
-		templateEngine.setTemplateResolver(templateResolver);
-		templateEngine.addDialect(new TilesDialect());
-		return templateEngine;
+	public TemplateEngine templateEngine() {
+		SpringTemplateEngine engine = new SpringTemplateEngine();
+		engine.setEnableSpringELCompiler(true);
+		engine.setTemplateResolver(templateResolver());
+		return engine;
 	}
 
-	@Bean
-	public ThymeleafViewResolver viewResolver(SpringTemplateEngine templateEngine) {
-		ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
-		viewResolver.setTemplateEngine(templateEngine);
-		viewResolver.setViewClass(ThymeleafTilesView.class);
-		return viewResolver;
+	private SpringResourceTemplateResolver templateResolver() {
+		SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
+		resolver.setPrefix("classpath:/views/");
+		resolver.setSuffix(".html");
+		resolver.setTemplateMode(TemplateMode.HTML);
+		resolver.setApplicationContext(applicationContext);
+		return resolver;
 	}
 
 	@Bean

+ 0 - 57
samples/javaconfig/messages/src/main/resources/tiles/tiles-def.xml

@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE tiles-definitions PUBLIC
-	   "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
-	   "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
-<tiles-definitions>
-
-  <definition name="messages/*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/messages/{1}"/>
-	<put-attribute name="title"
-		value="title/messages/{1}"/>
-	<put-attribute name="head"
-		value="head/messages/{1}"/>
-  </definition>
-
-  <definition name="content/messages/*"
-	  template="messages/{1} :: content"/>
-  <definition name="title/messages/*"
-	  template="messages/{1} :: title"/>
-  <definition name="head/messages/*"
-	  template="messages/{1} :: /html/head/link"/>
-
-  <definition name="user/*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/user/{1}"/>
-	<put-attribute name="title"
-		value="title/user/{1}"/>
-	<put-attribute name="head"
-		value="head/user/{1}"/>
-  </definition>
-
-  <definition name="content/user/*"
-	  template="user/{1} :: content"/>
-  <definition name="title/user/*"
-	  template="user/{1} :: title"/>
-  <definition name="head/user/*"
-	  template="user/{1} :: /html/head/link"/>
-
-  <definition name="*"
-	  template="layout">
-	<put-attribute name="content"
-		value="content/{1}"/>
-	<put-attribute name="title"
-		value="title/{1}"/>
-	<put-attribute name="head"
-		value="head/{1}"/>
-  </definition>
-
-  <definition name="content/*"
-	  template="{1} :: content"/>
-  <definition name="title/*"
-	  template="{1} :: title"/>
-  <definition name="head/*"
-	  template="{1} :: /html/head/link"/>
-</tiles-definitions>

+ 6 - 7
samples/javaconfig/messages/src/main/resources/views/layout.html

@@ -1,9 +1,8 @@
 <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:th="http://www.thymeleaf.org"
-      xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:include="title">SecureMail:</title>
+      xmlns:th="http://www.thymeleaf.org">
+  <head th:fragment="head(title,links)">
+    <title>SecureMail: <th:block th:include="${title}"></th:block></title>
     <link rel="icon" type="image/x-icon" th:href="@{/resources/img/favicon.ico}" href="../resources/img/favicon.ico"/>
     <link th:href="@{/resources/css/bootstrap.css}" href="../resources/css/bootstrap.css" rel="stylesheet"></link>
     <style type="text/css">
@@ -71,11 +70,11 @@
     <!--[if lt IE 9]>
       <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
-    <script tiles:replace="head"></script>
+    <th:block th:replace="${links}"/>
   </head>
 
 
-  <body>
+  <body th:fragment="body">
     <div id="wrap">
       <div class="navbar navbar-inverse navbar-static-top">
         <div class="navbar-inner">
@@ -105,7 +104,7 @@
               th:text="${globalMessage}">
             Some Success message
         </div>
-        <div tiles:substituteby="content">
+        <div th:replace="${content}">
             Fake content
         </div>
       </div>

+ 5 - 5
samples/javaconfig/messages/src/main/resources/views/messages/compose.html

@@ -1,9 +1,9 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Create</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{})">
+      <title>Create</title>
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+    <div th:fragment="content">
       <div class="container">
             <h1>Messages : Create</h1>
             <form id="messageForm"

+ 5 - 5
samples/javaconfig/messages/src/main/resources/views/messages/inbox.html

@@ -1,9 +1,9 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : View All</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{})">
+      <title>View All</title>
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+    <div th:fragment="content">
         <h1>Inbox</h1>
         <table class="table table-bordered table-striped">
             <thead>

+ 5 - 5
samples/javaconfig/messages/src/main/resources/views/messages/show.html

@@ -1,9 +1,9 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Create</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{})">
+      <title>Create</title>
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+    <div th:fragment="content">
         <div class="container">
             <h1>Message : <span th:text="${message.summary}">A short summary...</span></h1>
             <dl>

+ 6 - 6
samples/javaconfig/openid/src/main/resources/views/login.html

@@ -1,11 +1,11 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Login</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{::link})">
+    <title>Messages : Login</title>
     <!-- /Simple OpenID Selector -->
     <link rel="stylesheet" th:href="@{/resources/css/openid.css}" />
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+     <div th:fragment="content">
         <form name="f" th:action="@{/login/openid}" method="post" id="openid_form">
             <input type="hidden" name="action" value="verify" />
 	        <fieldset>
@@ -32,7 +32,7 @@
                 </noscript>
 	        </fieldset>
 	    </form>
-	    
+
     <script type="text/javascript" th:src="@{/resources/js/jquery-1.2.6.min.js}"><!-- --></script>
     <script type="text/javascript" th:src="@{/resources/js/openid-jquery.js}"><!-- --></script>
     <script type="text/javascript">

+ 5 - 5
samples/javaconfig/openid/src/main/resources/views/user/show.html

@@ -1,11 +1,11 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Login</title>
+<html xmlns:th="http://www.thymeleaf.org">
+  <head th:include="layout :: head(title=~{::title},links=~{})">
+    <title>Messages : Login</title>
     <!-- /Simple OpenID Selector -->
     <link rel="stylesheet" th:href="@{/resources/css/openid.css}" />
   </head>
-  <body>
-    <div tiles:fragment="content">
+  <body th:include="layout :: body" th:with="content=~{::content}">
+     <div th:fragment="content">
         <h1>User Attributes</h1>
         <table class="table table-border">
             <thead>

+ 23 - 26
samples/javaconfig/preauth/src/main/resources/views/login.html

@@ -1,27 +1,24 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Create</title>
-  </head>
-  <body>
-    <div tiles:fragment="content">
-      <form name="f" th:action="@{/j_security_check}" method="post">
-        <fieldset>
-            <legend>Please Login</legend>
-            <div th:if="${param.error}" class="alert alert-error">
-                    Invalid username and password.
-            </div>
-            <div th:if="${param.logout}" class="alert alert-success">
-                You have been logged out.
-            </div>
-            <label for="username">Username</label>
-            <input type="text" id="username" name="username"/>
-            <label for="password">Password</label>
-            <input type="password" id="password" name="password"/>
-            <div class="form-actions">
-                <button type="submit" class="btn">Log in</button>
-            </div>
-        </fieldset>
-    </form>
-    </div>
-  </body>
+<html xmlns:th="http://www.thymeleaf.org">
+    <head th:include="layout :: head(title=~{::title},links=~{})">
+        <title>Please Login</title>
+    </head>
+    <body th:include="layout :: body" th:with="content=~{::content}">
+        <div th:fragment="content">
+            <form name="f" th:action="@{/j_security_check}" method="post">
+                <fieldset>
+                    <legend>Please Login</legend>
+                    <div th:if="${param.error}" class="alert alert-error">Invalid
+                        username and password.</div>
+                    <div th:if="${param.logout}" class="alert alert-success">You
+                        have been logged out.</div>
+                    <label for="username">Username</label> <input type="text"
+                        id="username" name="username" /> <label for="password">Password</label>
+                    <input type="password" id="password" name="password" />
+                    <div class="form-actions">
+                        <button type="submit" class="btn">Log in</button>
+                    </div>
+                </fieldset>
+            </form>
+        </div>
+    </body>
 </html>

+ 25 - 28
samples/javaconfig/rememberme/src/main/resources/views/login.html

@@ -1,29 +1,26 @@
-<html xmlns:th="http://www.thymeleaf.org" xmlns:tiles="http://www.thymeleaf.org">
-  <head>
-    <title tiles:fragment="title">Messages : Create</title>
-  </head>
-  <body>
-    <div tiles:fragment="content">
-        <form name="f" th:action="@{/login}" method="post">
-	        <fieldset>
-	            <legend>Please Login</legend>
-                <div th:if="${param.error}" class="alert alert-error">
-                    Invalid username and password.
-                </div>
-                <div th:if="${param.logout}" class="alert alert-success">
-                    You have been logged out.
-                </div>
-	            <label for="username">Username</label>
-	            <input type="text" id="username" name="username"/>
-	            <label for="password">Password</label>
-	            <input type="password" id="password" name="password"/>
-	            <label for="remember-me">Remember Me?</label>
-                <input type="checkbox" id="remember-me" name="remember-me"/>
-	            <div class="form-actions">
-	                <button type="submit" class="btn">Log in</button>
-	            </div>
-	        </fieldset>
-	    </form>
-    </div>
-  </body>
+<html xmlns:th="http://www.thymeleaf.org">
+	<head th:include="layout :: head(title=~{::title},links=~{})">
+		<title>Please Login</title>
+	</head>
+	<body th:include="layout :: body" th:with="content=~{::content}">
+		<div th:fragment="content">
+			<form name="f" th:action="@{/login}" method="post">
+				<fieldset>
+					<legend>Please Login</legend>
+					<div th:if="${param.error}" class="alert alert-error">Invalid
+						username and password.</div>
+					<div th:if="${param.logout}" class="alert alert-success">You
+						have been logged out.</div>
+					<label for="username">Username</label> <input type="text"
+						id="username" name="username" /> <label for="password">Password</label>
+					<input type="password" id="password" name="password" /> <label
+						for="remember-me">Remember Me?</label> <input type="checkbox"
+						id="remember-me" name="remember-me" />
+					<div class="form-actions">
+						<button type="submit" class="btn">Log in</button>
+					</div>
+				</fieldset>
+			</form>
+		</div>
+	</body>
 </html>