Skip to content

Commit 7d8e60e

Browse files
author
paul.oconnell
committed
Add thymeleaf module
1 parent 1742bbf commit 7d8e60e

File tree

7 files changed

+176
-0
lines changed

7 files changed

+176
-0
lines changed

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>ie.emeraldjava.springboot</groupId>
7+
<artifactId>spring-boot-examples</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>pom</packaging>
10+
11+
<name>spring-boot-examples</name>
12+
13+
<modules>
14+
<module>thymeleaf</module>
15+
</modules>
16+
17+
</project>

thymeleaf/pom.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>ie.emeraldjava.springboot</groupId>
7+
<artifactId>spring-boot-thymeleaf</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>war</packaging>
10+
11+
<name>spring-boot-thymeleaf</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.5.1.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
</properties>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-web</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-tomcat</artifactId>
40+
<scope>provided</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-test</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-maven-plugin</artifactId>
54+
</plugin>
55+
</plugins>
56+
</build>
57+
58+
59+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ie.emeraldjava.springboot.thymeleaf;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
7+
import java.util.Map;
8+
9+
/**
10+
* Created by pauloconnell on 26/02/17.
11+
*/
12+
@Controller
13+
public class IndexController {
14+
15+
// inject via application.properties
16+
@Value("${welcome.message:test}")
17+
private String message = "Hello World";
18+
19+
@RequestMapping("/")
20+
public String welcome(Map<String, Object> model) {
21+
model.put("message", this.message);
22+
return "index";
23+
}
24+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ie.emeraldjava.springboot.thymeleaf;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringBootThymeleafApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringBootThymeleafApplication.class, args);
11+
}
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
welcome.message:test=index welcome message
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE HTML>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<title>Spring Boot Thymeleaf Hello World Example</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
7+
<link rel="stylesheet" type="text/css"
8+
href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />
9+
10+
<link rel="stylesheet" th:href="@{/css/main.css}"
11+
href="../../css/main.css" />
12+
13+
</head>
14+
<body>
15+
16+
<nav class="navbar navbar-inverse">
17+
<div class="container">
18+
<div class="navbar-header">
19+
<a class="navbar-brand" href="#">Spring Boot</a>
20+
</div>
21+
<div id="navbar" class="collapse navbar-collapse">
22+
<ul class="nav navbar-nav">
23+
<li class="active"><a href="#">Home</a></li>
24+
<li><a href="#about">About</a></li>
25+
</ul>
26+
</div>
27+
</div>
28+
</nav>
29+
30+
<div class="container">
31+
32+
<div class="starter-template">
33+
<h1>Spring Boot Web Thymeleaf Example</h1>
34+
<h2>
35+
<span th:text="'Message: ' + ${message}"></span>
36+
</h2>
37+
</div>
38+
39+
</div>
40+
<!-- /.container -->
41+
42+
<script type="text/javascript"
43+
src="webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
44+
45+
</body>
46+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ie.emeraldjava.springboot.thymeleaf;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class SpringBootThymeleafApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)