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
This commit is contained in:
Rob Winch 2016-10-17 09:12:24 -05:00
parent c1e9140940
commit 5e35e37a2b
24 changed files with 180 additions and 362 deletions

View File

@ -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>

View File

@ -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'

View File

@ -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) {

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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() }

View File

@ -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

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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() }

View File

@ -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() }

View File

@ -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'
}
}
}

View File

@ -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;
public ViewResolver viewResolver() {
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
resolver.setTemplateEngine(templateEngine());
resolver.setCharacterEncoding("UTF-8");
return resolver;
}
@Bean
public ThymeleafTilesConfigurer tilesConfigurer() {
ThymeleafTilesConfigurer tilesConfigurer = new ThymeleafTilesConfigurer();
tilesConfigurer.setDefinitions(new String[] { "classpath:tiles/tiles-def.xml" });
return tilesConfigurer;
public TemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
engine.setEnableSpringELCompiler(true);
engine.setTemplateResolver(templateResolver());
return engine;
}
@Bean
public SpringTemplateEngine templateEngine(
ClassLoaderTemplateResolver templateResolver) {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
templateEngine.addDialect(new TilesDialect());
return templateEngine;
}
@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

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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">

View File

@ -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>

View File

@ -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>

View File

@ -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>