Java + SpringBootでThymeleaf [ざっくり備忘録]
目次
はじめに
ちょっと迷ったので備忘録 筆者はmavenで開発しています。
Thymeleafの準備
pom.xmlにライブラリ追加
//追加 -> import <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
htmlに追加
<html xmlns:th="http://www.thymeleaf.org"> //省略
Springbootにおけるcssのリンク付け
下記のような形で記述(/css
などは、staticディレクトリからのパス。つまり、static\css\style.css)
<link href="/css/style.css" th:href="@{/css/style.css}" rel="stylesheet">
筆者は下記のように分けました。
- static\css
- static\images