{"id":1471,"date":"2025-03-21T15:22:38","date_gmt":"2025-03-21T06:22:38","guid":{"rendered":"https:\/\/route-zero.com\/recruit\/?post_type=route&#038;p=1471"},"modified":"2025-08-06T15:23:30","modified_gmt":"2025-08-06T06:23:30","slug":"thymeleaf%e5%85%a5%e9%96%80%e2%94%82spring-boot%e3%81%a710%e5%88%86%e5%ae%9f%e8%b7%b5%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab5%e9%81%b8","status":"publish","type":"route","link":"https:\/\/route-zero.com\/recruit\/route\/1471\/","title":{"rendered":"Thymeleaf\u5165\u9580\u2502Spring Boot\u306710\u5206\u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb5\u9078"},"content":{"rendered":"<div>\n<h1>10\u5206\u3067\u308f\u304b\u308bThymeleaf\u5165\u9580\u2014Spring Boot\u3067\u52d5\u304b\u3059\u30b5\u30f3\u30d7\u30eb5\u9078<\/h1>\n<p>\n    SpringBoot\u3067\u52d5\u7684HTML\u3092\u624b\u8efd\u306b\u66f8\u3051\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u3057\u3066\u4eba\u6c17\u306eThymeleaf\u3002\u3057\u304b\u3057\u300c\u57fa\u672c\u69cb\u6587\u306f\u308f\u304b\u3063\u305f\u3051\u3069\u3001\u5b9f\u969b\u306b\u3069\u3046\u4f7f\u3048\u3070\u3044\u3044\u304b\u30a4\u30e1\u30fc\u30b8\u304c\u6e67\u304b\u306a\u3044\u2026\u300d\u3068\u3044\u3046\u58f0\u3082\u591a\u3044\u306f\u305a\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001\u5b9f\u52d93\u5e74\u76ee\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u4f50\u85e4\u5927\u8f14\u3055\u3093\u304c\u76f4\u9762\u3057\u304c\u3061\u306a\u300c\u30b3\u30fc\u30c9\u306f\u52d5\u304f\u3051\u3069\u5473\u6c17\u306a\u3044\u300d\u300c\u305f\u3063\u305f\u3072\u3068\u624b\u9593\u3067UX\u3092\u683c\u4e0a\u3052\u3057\u305f\u3044\u300d\u3068\u3044\u3046\u60a9\u307f\u3092\u89e3\u6d88\u3059\u3079\u304f\u3001\u2460\u57fa\u672c\u69cb\u6587\u306e\u30dd\u30a4\u30f3\u30c8\u89e3\u8aac\uff0b\u2461\u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb5\u9078\u3092<strong>10\u5206\u3067\u7406\u89e3<\/strong>\u3067\u304d\u308b\u69cb\u6210\u3067\u304a\u5c4a\u3051\u3057\u307e\u3059\u3002\u3059\u3050\u306b\u30b3\u30d4\u30da\u3067\u304d\u308b\u30b3\u30fc\u30c9\uff06\u300c\u306a\u305c\u3053\u3046\u66f8\u304f\u306e\u304b\u300d\u306e\u80cc\u666f\u89e3\u8aac\u3067\u3001\u4eca\u3059\u3050\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5c0e\u5165\u53ef\u80fd\u3067\u3059\uff01\n  <\/p>\n<hr \/>\n<h2>1. Thymeleaf\u3068\u306f\uff1fSpring Boot\u3067\u9078\u3070\u308c\u308b\u7406\u7531<\/h2>\n<h3>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306e\u5f79\u5272<\/h3>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306f\u3001HTML\u306b\u52d5\u7684\u306a\u5024\u57cb\u3081\u8fbc\u307f\u3084\u6761\u4ef6\u5206\u5c90\u3001\u30eb\u30fc\u30d7\u51e6\u7406\u3092\u884c\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002JSP\u3084Freemarker\u3068\u6bd4\u3079\u3001Thymeleaf\u306f<strong>\u30ca\u30c1\u30e5\u30e9\u30eb\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/strong>\u3092\u63a1\u7528\u3057\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u958b\u3044\u3066\u3082\u30d7\u30ec\u30fc\u30f3HTML\u3068\u3057\u3066\u52d5\u4f5c\u3059\u308b\u305f\u3081\u3001\u30c7\u30b6\u30a4\u30ca\u30fc\u3084\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u62c5\u5f53\u3068\u306e\u5354\u696d\u304c\u975e\u5e38\u306b\u30b9\u30e0\u30fc\u30ba\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30ca\u30c1\u30e5\u30e9\u30eb\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u30ca\u30c1\u30e5\u30e9\u30eb\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<\/strong>\uff1aHTML\u30d5\u30a1\u30a4\u30eb\u81ea\u4f53\u306b\u76f4\u63a5Thymeleaf\u306e\u69cb\u6587\u3092\u8a18\u8ff0\u3059\u308b\u5f62\u5f0f\u3002\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3092\u901a\u3055\u305a\u306b\u30d6\u30e9\u30a6\u30b6\u3067\u958b\u3044\u3066\u3082\u3001\u30d7\u30ec\u30fc\u30f3\u306aHTML\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u308b\u306e\u304c\u7279\u5fb4\u3067\u3059\u3002<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<h3>Thymeleaf\u306e\u7279\u5fb4\u3068\u512a\u4f4d\u70b9<\/h3>\n<ul>\n<li><strong>\u81ea\u7136\u306aHTML\u69cb\u6587<\/strong>\uff1a<code>&lt;span th:text=\"\u2026\"&gt;<\/code>\u306e\u3088\u3046\u306b\u5c5e\u6027\u3060\u3051\u3092\u8ffd\u52a0<\/li>\n<li><strong>Spring\u9023\u643a\u304c\u7c21\u5358<\/strong>\uff1a<code>spring-boot-starter-thymeleaf<\/code>\u3092\u8ffd\u52a0\u3059\u308b\u3060\u3051\uff08<a href=\"https:\/\/route-zero.com\/recruit\/route\/1269\/\">MVC\u69cb\u6210\u3092\u7406\u89e3\u3059\u308c\u3070\u73fe\u5834\u3067\u8a70\u307e\u3089\u306a\u3044 | Spring Boot\u5b9f\u88c5\u30ac\u30a4\u30c9<\/a>\uff09<\/li>\n<li><strong>\u5b89\u5168\u306a\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406<\/strong>\uff1aXSS\u5bfe\u7b56\u6e08\u307f\u306e\u5909\u6570\u51fa\u529b<\/li>\n<li><strong>\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u7ba1\u7406<\/strong>\uff1a\u30d8\u30c3\u30c0\u30fc\uff0f\u30d5\u30c3\u30bf\u30fc\u306a\u3069\u5171\u901a\u90e8\u54c1\u3092\u5bb9\u6613\u306b\u518d\u5229\u7528<\/li>\n<\/ul>\n<hr \/>\n<h2>2. \u5c0e\u5165\u624b\u9806\uff1aSpring Boot\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306e\u7d44\u307f\u8fbc\u307f<\/h2>\n<h3>2.1 \u4f9d\u5b58\u8a2d\u5b9a\uff08Maven\uff0fGradle\uff09<\/h3>\n<pre><code class=\"language-xml\" title=\"pom.xml\">&lt;dependency&gt;\r\n  &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n  &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;\/artifactId&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<pre><code class=\"language-groovy\" title=\"build.gradle\">implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'\r\n<\/code><\/pre>\n<h3>2.2 application.properties \u306e\u8a2d\u5b9a<\/h3>\n<pre><code class=\"language-properties\">spring.thymeleaf.prefix=classpath:\/templates\/\r\nspring.thymeleaf.suffix=.html\r\nspring.thymeleaf.cache=false # \u958b\u767a\u6642\u306ffalse\u63a8\u5968\r\n<\/code><\/pre>\n<h3>2.3 \u57fa\u672c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h3>\n<pre><code>src\/\r\n\u2514 templates\/\r\n  \u251c index.html\r\n  \u2514 fragments\/\r\n    \u251c header.html\r\n    \u2514 footer.html\r\n<\/code><\/pre>\n<hr \/>\n<h2>3. \u57fa\u672c\u69cb\u65875\u9078\uff0b\u6df1\u6398\u308a\u89e3\u8aac<\/h2>\n<p>\u3053\u3053\u304b\u3089\u306fThymeleaf\u306e\u4ee3\u8868\u7684\u306a\u5c5e\u6027\u3092\u3001<strong>\u300c\u306a\u305c\u5fc5\u8981\u304b\u300d\u300c\u3069\u3093\u306a\u5834\u9762\u3067\u6d3b\u304d\u308b\u304b\u300d\u300c\u5b9f\u88c5\u6642\u306e\u6ce8\u610f\u70b9\u300d<\/strong>\u3068\u3068\u3082\u306b\u5177\u4f53\u4f8b\u3067\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h3>3.1 <code>th:text<\/code>\uff1a\u5909\u6570\u57cb\u3081\u8fbc\u307f\u306e\u57fa\u672c<\/h3>\n<h4>\u89e3\u8aac<\/h4>\n<p>HTML\u8981\u7d20\u306e\u30c6\u30ad\u30b9\u30c8\u30ce\u30fc\u30c9\u90e8\u5206\u306b\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306e\u5909\u6570\u5024\u3092\u5b89\u5168\u306b\u57cb\u3081\u8fbc\u3080\u69cb\u6587\u3002\u81ea\u52d5\u3067HTML\u30a8\u30b9\u30b1\u30fc\u30d7\u304c\u884c\u308f\u308c\u308b\u305f\u3081\u3001\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u5024\u3092\u305d\u306e\u307e\u307e\u51fa\u529b\u3057\u3066\u3082XSS\u653b\u6483\u3092\u9632\u3052\u307e\u3059\u3002<\/p>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1aXSS\uff08\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0\uff09<\/strong><\/p>\n<ul>\n<li>\n<p><strong>XSS<\/strong>\uff1aWeb\u30b5\u30a4\u30c8\u306e\u8106\u5f31\u6027\u3092\u60aa\u7528\u3057\u305f\u653b\u6483\u624b\u6cd5\u3002\u60aa\u610f\u306e\u3042\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u57cb\u3081\u8fbc\u307f\u3001\u8a2a\u554f\u30e6\u30fc\u30b6\u30fc\u306e\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u5b9f\u884c\u3055\u305b\u308b\u3053\u3068\u3067\u3001\u500b\u4eba\u60c5\u5831\u306e\u7a83\u53d6\u306a\u3069\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<h4>\u4f8b\uff1a\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u8868\u793a<\/h4>\n<pre><code class=\"language-java\">\/\/ Controller\r\n@GetMapping(\"\/profile\")\r\npublic String profile(Model model) {\r\n  model.addAttribute(\"username\", \"&lt;script&gt;alert('XSS')&lt;\/script&gt;\");\r\n  return \"profile\";\r\n}\r\n<\/code><\/pre>\n<pre><code class=\"language-html\" title=\"profile.html\">&lt;p&gt;\u3088\u3046\u3053\u305d\u3001&lt;span th:text=\"${username}\"&gt;[User]&lt;\/span&gt;\u3055\u3093\uff01&lt;\/p&gt;\r\n<\/code><\/pre>\n<ul>\n<li>\n      <strong>\u52d5\u4f5c\u30dd\u30a4\u30f3\u30c8<\/strong><\/p>\n<ul>\n<li><code>&lt;script&gt;<\/code>\u30bf\u30b0\u306f\u6587\u5b57\u5217\u3068\u3057\u3066\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3055\u308c\u3001\u5b9f\u884c\u3055\u308c\u307e\u305b\u3093\u3002<\/li>\n<li>\u5fc5\u305a<code>th:text<\/code>\u3092\u4f7f\u3044\u3001\u76f4\u66f8\u304d\u306e\u751fHTML\u3092\u907f\u3051\u307e\u3057\u3087\u3046\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3.2 <code>th:each<\/code>\uff1a\u30ea\u30b9\u30c8\uff0f\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u30eb\u30fc\u30d7\u51e6\u7406<\/h3>\n<h4>\u89e3\u8aac<\/h4>\n<p>Java\u306e<code>List<\/code>\u3084\u914d\u5217\u3092HTML\u8981\u7d20\u3068\u3057\u3066\u53cd\u5fa9\u51fa\u529b\u3057\u307e\u3059\u3002\u30b9\u30c6\u30fc\u30bf\u30b9\u5909\u6570\u3092\u4f7f\u3048\u3070\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3084\u521d\u56de\u30fb\u6700\u7d42\u56de\u5224\u5b9a\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-java\">\/\/ Controller\r\n@GetMapping(\"\/products\")\r\npublic String products(Model model) {\r\n  List&lt;Product&gt; products = List.of(\r\n    new Product(1, \"\u30ea\u30f3\u30b4\", 120),\r\n    new Product(2, \"\u30d0\u30ca\u30ca\", 80));\r\n  model.addAttribute(\"products\", products);\r\n  return \"products\";\r\n}\r\n<\/code><\/pre>\n<pre><code class=\"language-html\" title=\"products.html\">&lt;table&gt;\r\n  &lt;tr&gt;&lt;th&gt;#&lt;\/th&gt;&lt;th&gt;\u5546\u54c1\u540d&lt;\/th&gt;&lt;th&gt;\u4fa1\u683c&lt;\/th&gt;&lt;\/tr&gt;\r\n  &lt;tr th:each=\"p, stat : ${products}\"&gt;\r\n    &lt;td th:text=\"${stat.index + 1}\"&gt;1&lt;\/td&gt;\r\n    &lt;td th:text=\"${p.name}\"&gt;\u5546\u54c1\u540d&lt;\/td&gt;\r\n    &lt;td th:text=\"${p.price} + '\u5186'\"&gt;\u4fa1\u683c&lt;\/td&gt;\r\n  &lt;\/tr&gt;\r\n  &lt;tr th:if=\"${products.empty}\"&gt;\r\n    &lt;td colspan=\"3\"&gt;\u5546\u54c1\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093&lt;\/td&gt;\r\n  &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n<\/code><\/pre>\n<h4>\u52d5\u4f5c\u30dd\u30a4\u30f3\u30c8<\/h4>\n<ul>\n<li><code>th:each=\"p, stat : ${products}\"<\/code> \u3067\u3001<code>stat.index<\/code>\uff080\u958b\u59cb\uff09\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>\u7a7a\u30ea\u30b9\u30c8\u6642\u306f <code>products.empty<\/code> \u306b\u3088\u308a\u300c\u5546\u54c1\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u300d\u306e\u884c\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/li>\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u8868\u793a\u30a4\u30e1\u30fc\u30b8<\/strong>\uff1a<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>#<\/th>\n<th>\u5546\u54c1\u540d<\/th>\n<th>\u4fa1\u683c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u30ea\u30f3\u30b4<\/td>\n<td>120\u5186<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u30d0\u30ca\u30ca<\/td>\n<td>80\u5186<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n      <strong>\u6ce8\u610f\u70b9<\/strong>\uff1a<\/p>\n<ul>\n<li>\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306egetter\u304c\u6b63\u3057\u304f\u547d\u540d\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u30c7\u30fc\u30bf\u304c\u6e21\u308a\u307e\u305b\u3093\u3002<\/li>\n<li>\u5927\u91cf\u30c7\u30fc\u30bf\u3092\u4e00\u5ea6\u306b\u51fa\u529b\u3059\u308b\u3068\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u5f71\u97ff\u304c\u51fa\u308b\u305f\u3081\u3001\u30da\u30fc\u30b8\u30cd\u30fc\u30b7\u30e7\u30f3\u3084\u90e8\u5206\u66f4\u65b0\uff08Ajax\uff09\u3092\u691c\u8a0e\u3057\u307e\u3057\u3087\u3046\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3.3 <code>th:if<\/code>\uff0f<code>th:unless<\/code>\uff1a\u6761\u4ef6\u5206\u5c90\u306e\u4f7f\u3044\u5206\u3051<\/h3>\n<h4>\u89e3\u8aac<\/h4>\n<p><code>th:if<\/code>\u306f\u6761\u4ef6\u304ctrue\u306e\u3068\u304d\u306b\u8981\u7d20\u3092\u51fa\u529b\u3057\u3001<code>th:unless<\/code>\u306ffalse\u306e\u3068\u304d\u306b\u51fa\u529b\u3002\u30cd\u30b9\u30c8\u304c\u6df1\u304f\u306a\u308b\u5834\u5408\u306f<code>&lt;th:block&gt;<\/code>\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>\u4f8b\uff1a\u7ba1\u7406\u8005\u306e\u307f\u7de8\u96c6\u30dc\u30bf\u30f3\u8868\u793a<\/h4>\n<pre><code class=\"language-html\">&lt;div&gt;\r\n  &lt;button th:if=\"${user.admin}\" th:onclick=\"'location.href=\\'\/edit\\''\"&gt;\u7de8\u96c6&lt;\/button&gt;\r\n  &lt;p th:unless=\"${user.admin}\"&gt;\u203b\u7de8\u96c6\u6a29\u9650\u304c\u3042\u308a\u307e\u305b\u3093&lt;\/p&gt;\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\n<ul>\n<li>\n      <strong>\u52d5\u4f5c\u30dd\u30a4\u30f3\u30c8<\/strong><\/p>\n<ul>\n<li>Java\u5074\u3067<code>user<\/code>\u304cnull\u3060\u3068NPE\u306b\u306a\u308b\u305f\u3081\u3001\u4e8b\u524d\u30c1\u30a7\u30c3\u30af\u3092\u3002<\/li>\n<li>\u8907\u6570\u8981\u7d20\u3092\u307e\u3068\u3081\u3066\u5236\u5fa1\u3057\u305f\u3044\u5834\u5408\u306f<code>&lt;th:block th:if=\"\u2026\"&gt;\u2026&lt;\/th:block&gt;<\/code>\u3092\u6d3b\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3.4 <code>@{...}<\/code>\uff1a\u30d1\u30b9\u89e3\u6c7a\uff0f\u30ea\u30f3\u30af\u751f\u6210<\/h3>\n<h4>\u89e3\u8aac<\/h4>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3092\u542b\u3081\u3066URL\u3092\u81ea\u52d5\u751f\u6210\u3002\u30d1\u30e9\u30e1\u30fc\u30bf\u4ed8\u304d\u30ea\u30f3\u30af\u3084\u30af\u30a8\u30ea\u6587\u5b57\u5217\u3082\u7c21\u5358\u306b\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>\u4f8b\uff1a\u30e6\u30fc\u30b6\u30fc\u8a73\u7d30\u30da\u30fc\u30b8\u3078\u306e\u30ea\u30f3\u30af<\/h4>\n<pre><code class=\"language-html\">&lt;a th:href=\"@{\/users\/{id}(id=${user.id})}\">\u8a73\u7d30\u3078&lt;\/a&gt;\r\n<\/code><\/pre>\n<ul>\n<li>\n      <strong>\u52d5\u4f5c\u30dd\u30a4\u30f3\u30c8<\/strong><\/p>\n<ul>\n<li><code>{id}<\/code>\u306e\u540d\u524d\u3068\u5909\u6570\u540d\u3092\u4e00\u81f4\u3055\u305b\u308b\u3002<\/li>\n<li>\u30af\u30a8\u30ea\u6587\u5b57\u5217\u306f <code>@{\/search(q=${q},page=1)}<\/code> \u306e\u3088\u3046\u306b\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3.5 <code>th:fragment<\/code>\uff1a\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u306b\u3088\u308b\u518d\u5229\u7528<\/h3>\n<h4>\u89e3\u8aac<\/h4>\n<p>\u90e8\u5206\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\uff08\u30d8\u30c3\u30c0\u30fc\u3001\u30d5\u30c3\u30bf\u30fc\u3001\u30e2\u30fc\u30c0\u30eb\u90e8\u54c1\u306a\u3069\uff09\u3092\u5916\u90e8\u30d5\u30a1\u30a4\u30eb\u306b\u5b9a\u7fa9\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u633f\u5165\u30fb\u7f6e\u63db\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4>\u4f8b\uff1a\u5171\u901a\u30d8\u30c3\u30c0\u30fc\u306e\u5b9a\u7fa9\u3068\u633f\u5165<\/h4>\n<pre><code class=\"language-html\" title=\"fragments\/header.html\">&lt;header th:fragment=\"mainHeader(title)\"&gt;\r\n  &lt;h1 th:text=\"${title}\"&gt;\u30b5\u30a4\u30c8\u30bf\u30a4\u30c8\u30eb&lt;\/h1&gt;\r\n  &lt;nav&gt;\u2026&lt;\/nav&gt;\r\n&lt;\/header&gt;\r\n<\/code><\/pre>\n<pre><code class=\"language-html\" title=\"index.html\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n  &lt;body&gt;\r\n    &lt;!-- \u633f\u5165 --&gt;\r\n    &lt;div th:insert=\"fragments\/header :: mainHeader('\u30db\u30fc\u30e0')\"&gt;&lt;\/div&gt;\r\n    &lt;p&gt;\u672c\u6587\u30b3\u30f3\u30c6\u30f3\u30c4&lt;\/p&gt;\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<ul>\n<li>\n      <strong>\u52d5\u4f5c\u30dd\u30a4\u30f3\u30c8<\/strong><\/p>\n<ul>\n<li><code>th:insert<\/code>\u306f\u4e2d\u8eab\u3060\u3051\u633f\u5165\u3001<code>th:replace<\/code>\u306f\u30bf\u30b0\u3054\u3068\u7f6e\u63db\u3002<\/li>\n<li>\u5f15\u6570\u4ed8\u304d\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u3067\u6c4e\u7528\u6027\u3092\u9ad8\u3081\u308b\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>4. \u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb5\u9078<\/h2>\n<h3>\u30b5\u30f3\u30d7\u30eb\u2460\uff1a\u52d5\u7684\u306a\u30c6\u30fc\u30d6\u30eb\u4e00\u89a7\u8868\u793a<\/h3>\n<p>\uff08\u524d\u7bc03.2\u306e\u4f8b\u53c2\u7167\uff09<\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u2461\uff1a\u30d5\u30a9\u30fc\u30e0\u306e\u30d7\u30ea\u30bb\u30c3\u30c8\u5024\uff06\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u9023\u643a<\/h3>\n<pre><code class=\"language-html\">&lt;form th:action=\"@{\/user\/save}\" th:object=\"${user}\" method=\"post\"&gt;\r\n  &lt;input th:field=\"*{name}\" placeholder=\"\u540d\u524d\" \/&gt;\r\n  &lt;div th:if=\"${#fields.hasErrors('name')}\" th:errors=\"*{name}\"&gt;\u30a8\u30e9\u30fc&lt;\/div&gt;\r\n  &lt;button type=\"submit\"&gt;\u9001\u4fe1&lt;\/button&gt;\r\n&lt;\/form&gt;\r\n<\/code><\/pre>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1a\u30d5\u30a9\u30fc\u30e0\u306e\u30d7\u30ea\u30bb\u30c3\u30c8\u5024 \/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u30d7\u30ea\u30bb\u30c3\u30c8\u5024<\/strong>\uff1a\u30d5\u30a9\u30fc\u30e0\u306e\u5165\u529b\u6b04\u306b\u3042\u3089\u304b\u3058\u3081\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u5024\u306e\u3053\u3068\u3002\u7de8\u96c6\u753b\u9762\u306a\u3069\u3067\u65e2\u5b58\u306e\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3055\u305b\u308b\u969b\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/strong>\uff1a\u5165\u529b\u3055\u308c\u305f\u30c7\u30fc\u30bf\u304c\u6b63\u3057\u3044\u5f62\u5f0f\u3084\u6761\u4ef6\u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u304b\u691c\u8a3c\u3059\u308b\u4ed5\u7d44\u307f\u3002\u4f8b\u3048\u3070\u300c\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u5f62\u5f0f\u304c\u6b63\u3057\u3044\u304b\u300d\u306a\u3069\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<h3>\u30b5\u30f3\u30d7\u30eb\u2462\uff1a\u30cd\u30b9\u30c8\u69cb\u9020\u3067\u306e\u30eb\u30fc\u30d7\u8868\u793a\uff08DTO\u30ea\u30b9\u30c8\uff09<\/h3>\n<pre><code class=\"language-html\">&lt;div th:each=\"order : ${orders}\"&gt;\r\n  &lt;h2 th:text=\"${order.id} + '\u4ef6\u76ee'\"&gt;&lt;\/h2&gt;\r\n  &lt;ul&gt;\r\n    &lt;li th:each=\"item : ${order.items}\" th:text=\"${item.productName}\"&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1aDTO\uff08Data Transfer Object\uff09<\/strong><\/p>\n<ul>\n<li>\n<p><strong>DTO<\/strong>\uff1a\u30c7\u30fc\u30bf\u8ee2\u9001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u7565\u3002\u8907\u6570\u306e\u30c7\u30fc\u30bf\u3092\u3072\u3068\u307e\u3068\u3081\u306b\u3057\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3084\u30d3\u30e5\u30fc\u9593\u3067\u3084\u308a\u53d6\u308a\u3059\u308b\u969b\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u7121\u99c4\u306a\u30c7\u30fc\u30bf\u3092\u542b\u3081\u305a\u3001\u5fc5\u8981\u306a\u60c5\u5831\u3060\u3051\u3092\u6e21\u3059\u306e\u304c\u30dd\u30a4\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<h3>\u30b5\u30f3\u30d7\u30eb\u2463\uff1a\u30ab\u30b9\u30bf\u30e0\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u3092\u4f7f\u3063\u305f\u5171\u901a\u30d8\u30c3\u30c0\u30fc\uff0f\u30d5\u30c3\u30bf\u30fc<\/h3>\n<p>\uff08\u524d\u7bc03.5\u306e\u4f8b\u53c2\u7167\uff09<\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u2464\uff1aAjax\u9023\u643a\u3067\u90e8\u5206\u66f4\u65b0\u3059\u308b\u30d3\u30e5\u30fc<\/h3>\n<pre><code class=\"language-html\">&lt;div id=\"commentList\" th:fragment=\"list\"&gt;\r\n  &lt;p th:each=\"c : ${comments}\" th:text=\"${c.text}\"&gt;&lt;\/p&gt;\r\n&lt;\/div&gt;\r\n&lt;script&gt;\r\n  fetch('\/comments\/fragment')\r\n  .then(res =&gt; res.text())\r\n  .then(html =&gt; document.getElementById('commentList').innerHTML = html);\r\n&lt;\/script&gt;\r\n<\/code><\/pre>\n<blockquote>\n<p><strong>\u7528\u8a9e\u89e3\u8aac\uff1aAjax\uff08Asynchronous JavaScript + XML\uff09<\/strong><\/p>\n<ul>\n<li>\n<p>\n          <strong>Ajax<\/strong>\uff1aWeb\u30da\u30fc\u30b8\u3092\u30ea\u30ed\u30fc\u30c9\uff08\u518d\u8aad\u307f\u8fbc\u307f\uff09\u305b\u305a\u306b\u30b5\u30fc\u30d0\u30fc\u3068\u901a\u4fe1\u3057\u3001\u8868\u793a\u5185\u5bb9\u3092\u52d5\u7684\u306b\u66f4\u65b0\u3059\u308b\u6280\u8853\u3002\u975e\u540c\u671f\u901a\u4fe1\u306b\u3088\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u4f53\u9a13\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08<a href=\"https:\/\/route-zero.com\/recruit\/route\/1128\/\"\n            >JavaScript\u306eAjax\u5b8c\u5168\u5165\u9580\uff5cfetch\u306e\u4f7f\u3044\u65b9\u30fbCORS\u30a8\u30e9\u30fc\u306e\u5bfe\u51e6\u30fb\u975e\u540c\u671f\u901a\u4fe1\u306e\u57fa\u672c\u3092\u89e3\u8aac<\/a\n          >\uff09\n        <\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<hr \/>\n<h2>5. \u5b9f\u52d9\u3067\u3042\u308a\u304c\u3061\u306a\u300c\u843d\u3068\u3057\u7a74\u300d\u3068\u5bfe\u7b56<\/h2>\n<ul>\n<li><strong>BindingResult\u3092\u5fd8\u308c\u3066\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u98db\u3076<\/strong><\/li>\n<\/ul>\n<pre><code class=\"language-java\">public String save(@Valid @ModelAttribute User user, BindingResult result) { \u2026 }\r\n<\/code><\/pre>\n<p>\n    \u2192 <strong>\u9806\u5e8f\u3092<code>@Valid<\/code>\u2192<code>BindingResult<\/code><\/strong\n    >\u306b\u3002\uff08<a href=\"https:\/\/route-zero.com\/recruit\/route\/1115\/\">Spring Boot \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5165\u9580\uff5cMVC\u7d71\u5408\u3068\u30ab\u30b9\u30bf\u30e0\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u5b9f\u8df5\u4f8b<\/a>\uff09\n  <\/p>\n<ul>\n<li>\n      <strong>\u30cd\u30b9\u30c8DTO\u3067<code>th:each<\/code>\u304c\u52d5\u304b\u306a\u3044<\/strong><br \/>\n      \u2192 \u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3068Java\u306egetter\u540d\u3092\u4e00\u81f4\u3055\u305b\u308b\u3002\n    <\/li>\n<li>\n      <strong>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u958b\u767a\u53cd\u6620\u3055\u308c\u306a\u3044<\/strong><br \/>\n      \u2192 <code>spring.thymeleaf.cache=false<\/code>\u3092\u8a2d\u5b9a\u3002\n    <\/li>\n<\/ul>\n<hr \/>\n<h2>6. ChatGPT\u3067Thymeleaf\u30b3\u30fc\u30c9\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u30d7\u30ed\u30f3\u30d7\u30c8\u4f8b<\/h2>\n<pre><code>\u300cSpring Boot + Thymeleaf \u3067\u3001\u30ea\u30b9\u30c8\u8868\u793a\u7528\u306e&lt;table&gt;\u3068&lt;th:each&gt;\u306b\u3088\u308b\u30eb\u30fc\u30d7\u51e6\u7406\u3001@Controller\u304b\u3089\u306eModel\u9023\u643a\u307e\u3067\u542b\u3081\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u6559\u3048\u3066\u304f\u3060\u3055\u3044\u3002\u300d\r\n<\/code><\/pre>\n<ul>\n<li><strong>\u751f\u6210\u6642\u306e\u6ce8\u610f<\/strong>\uff1a\u5909\u6570\u540d\u3092\u660e\u78ba\u306b\u3057\u3001DTO\u306e\u30d1\u30c3\u30b1\u30fc\u30b8import\u3092\u88dc\u3046\u3002\uff08<a href=\"https:\/\/route-zero.com\/recruit\/route\/1353\/\">\u5b9f\u52d9\u3067\u4f7f\u3048\u308bAI\u30d7\u30ed\u30f3\u30d7\u30c8\u5b8c\u5168\u30c6\u30f3\u30d7\u30ec\uff5c\u521d\u5fc3\u8005\u5411\u3051\u69cb\u9020\uff0b\u6210\u529f\u4f8b\u4ed8\u304d\u624b\u9806<\/a>\uff09<\/li>\n<\/ul>\n<hr \/>\n<h2>7. FAQ\uff08\u3088\u304f\u3042\u308b\u8cea\u554f\uff09<\/h2>\n<p>\n    <strong>Q1. Thymeleaf\u3068Freemarker\u3001\u3069\u3061\u3089\u3092\u9078\u3079\u3070\u3044\u3044\uff1f<\/strong><br \/>\n    \u81ea\u7136\u306aHTML\u7de8\u96c6\u304c\u512a\u5148\u306a\u3089Thymeleaf\u3001\u30bf\u30b0\u30ab\u30b9\u30bf\u30e0\u3084\u9ad8\u901f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u306a\u3089Freemarker\u3002\n  <\/p>\n<p>\n    <strong>Q2. \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u52b9\u5316\u3059\u308b\u306b\u306f\uff1f<\/strong><br \/>\n    <code>application.properties<\/code>\u306b<code>spring.thymeleaf.cache=false<\/code>\u3092\u8ffd\u52a0\u3002\n  <\/p>\n<p>\n    <strong>Q3. prefers-reduced-motion\u5bfe\u5fdc\u306f\u53ef\u80fd\uff1f<\/strong><br \/>\n    CSS\u3067<code>@media (prefers-reduced-motion: reduce)<\/code>\u3092\u4f7f\u3044\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u6291\u5236\u3002\n  <\/p>\n<hr \/>\n<h2>8. \u307e\u3068\u3081\u3068\u6b21\u306b\u8aad\u3080\u3079\u304d\u8a18\u4e8b\u30ea\u30f3\u30af<\/h2>\n<p>\u672c\u8a18\u4e8b\u3067\u306f\u3001<strong>10\u5206\u3067\u7406\u89e3\u3067\u304d\u308bThymeleaf\u306e\u57fa\u672c\u69cb\u6587<\/strong>\u3068<strong>\u5b9f\u8df5\u30b5\u30f3\u30d7\u30eb5\u9078<\/strong>\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002\u624b\u65e9\u304f\u30b3\u30d4\u30da\u5b9f\u88c5\u3057\u3064\u3064\u300c\u306a\u305c\u3053\u3046\u66f8\u304f\u304b\u300d\u307e\u3067\u62bc\u3055\u3048\u3089\u308c\u308b\u69cb\u6210\u306a\u306e\u3067\u3001\u305c\u3072\u65e2\u5b58\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u53d6\u308a\u5165\u308c\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>\n      \u6b21\u306b\u8aad\u3080\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/route-zero.com\/recruit\/route\/1115\/\">Spring Boot\u30d5\u30a9\u30fc\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5fb9\u5e95\u653b\u7565<\/a><\/li>\n<li><a href=\"https:\/\/route-zero.com\/recruit\/route\/1353\/\">ChatGPT\u6d3b\u7528\u30d7\u30ed\u30f3\u30d7\u30c8\u6539\u5584\u8853<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>\u53c2\u8003\u6587\u732e\u30fb\u60c5\u5831\u6e90<\/strong><\/p>\n<ul>\n<li>Spring Boot\u516c\u5f0f\u30b9\u30bf\u30fc\u30bf\u30fc: <a href=\"https:\/\/spring.io\/projects\/spring-boot\">https:\/\/spring.io\/projects\/spring-boot<\/a><\/li>\n<li>Thymeleaf\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8: <a href=\"https:\/\/www.thymeleaf.org\/documentation.html\">https:\/\/www.thymeleaf.org\/documentation.html<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"featured_media":1473,"template":"","_links":{"self":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route\/1471"}],"collection":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/route"}],"about":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/types\/route"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media\/1473"}],"wp:attachment":[{"href":"https:\/\/route-zero.com\/recruit\/wp-json\/wp\/v2\/media?parent=1471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}