{"id":2935,"date":"2018-05-19T19:42:27","date_gmt":"2018-05-19T10:42:27","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=2935"},"modified":"2023-05-27T23:09:32","modified_gmt":"2023-05-27T14:09:32","slug":"%e3%80%90spring-boot%e3%80%91%e3%80%8cthymeleaf%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%aa%e3%83%bc%e3%83%95%e3%80%8d%e3%81%a7%e3%81%be%e3%81%a8%e3%81%be%e3%81%a3%e3%81%9f%e5%80%a4%e3%82%92%e6%b8%a1","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=2935","title":{"rendered":"\u3010Spring Boot\u3011\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5)\u300d\u3067\u753b\u9762\u306b\u307e\u3068\u307e\u3063\u305f\u5024\u3092\u6e21\u305d\u3046\u3002"},"content":{"rendered":"<p>\u4e0b\u8a18\u306e\u8a18\u4e8b\u306b\u3066\u3001\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5\uff09\u300d\u3067\u5024\u3092\u6e21\u3057\u3066\u3001\u753b\u9762\u306b\u8868\u793a\u3059\u308b\u624b\u9806\u3084\u30b5\u30f3\u30d7\u30eb\u3092\u3054\u7d39\u4ecb\u3055\u305b\u3066\u9802\u304d\u307e\u3057\u305f\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"NCn3FM4mBA\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=2906\">\u3010Spring Boot\u3011\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5)\u300d\u3067\u30d3\u30e5\u30fc\u3092\u4f5c\u308d\u3046\u3002(Hello World)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=2906&#038;embed=true#?secret=NCn3FM4mBA\" data-secret=\"NCn3FM4mBA\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Spring Boot\u3011\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5)\u300d\u3067\u30d3\u30e5\u30fc\u3092\u4f5c\u308d\u3046\u3002(Hello World)&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u3067\u306f\u3001\u8907\u6570\u306e\u307e\u3068\u307e\u3063\u305f\u5024\u3092\u753b\u9762\u306b\u6e21\u3057\u305f\u3044\u5834\u5408\u306f\u3069\u3046\u3059\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>JSP\u3084\u3001\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u306e\u5834\u5408\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30c7\u30fc\u30bf\u306e\u307e\u3068\u307e\u308a\u3068\u3057\u3066JavaBean\u3092\u4f5c\u3063\u3066\u6e21\u3059<\/strong><\/span>\u3068\u3044\u3046\u3053\u3068\u304c\u5f53\u305f\u308a\u524d\u3067\u3059\u306d\u3002<\/p>\n<p>\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5\uff09\u300d\u3067\u3082\u6982\u306d\u540c\u3058\u3088\u3046\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3002<\/h2>\n<h3>Person.java(\u5024\u3092\u307e\u3068\u3081\u3066\u6e21\u3059\u7528\u306eBean)<\/h3>\n<pre class=\"lang:default decode:true \">package com.example.demo;\r\n\r\npublic class Person {\r\n\r\n\tprivate String firstName;\r\n\tprivate String LastName;\r\n\tprivate int age;\r\n\r\n\t\/**\r\n\t * \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n\t *\/\r\n\tPerson(String firstName,String lastName,int age){\r\n\t\tthis.firstName = firstName;\r\n\t\tthis.LastName = lastName;\r\n\t\tthis.age = age;\r\n\t}\r\n\r\n\tpublic String getFirstName() {\r\n\t\treturn firstName;\r\n\t}\r\n\tpublic void setFirstName(String firstName) {\r\n\t\tthis.firstName = firstName;\r\n\t}\r\n\tpublic String getLastName() {\r\n\t\treturn LastName;\r\n\t}\r\n\tpublic void setLastName(String lastName) {\r\n\t\tLastName = lastName;\r\n\t}\r\n\tpublic int getAge() {\r\n\t\treturn age;\r\n\t}\r\n\tpublic void setAge(int age) {\r\n\t\tthis.age = age;\r\n\t}\r\n}\r\n<\/pre>\n<h3>SpringController.java(\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\uff09<\/h3>\n<pre class=\"lang:default decode:true \">package com.example.demo;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.Model;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\n\r\n@Controller\r\npublic class SpringController {\r\n\r\n    @RequestMapping(\"\/hello\")\r\n    public String hello(Model model) {\r\n    \tPerson person = new Person(\"\u592a\u90ce\",\"\u5c71\u7530\",18);\r\n\r\n    \tmodel.addAttribute(\"person\",person);\r\n    \tmodel.addAttribute(\"hello\",\"\u3053\u3093\u306b\u3061\u306f\");\r\n        return \"hello\";\r\n    }\r\n}<\/pre>\n<h3>hello.html(\u30d3\u30e5\u30fc\uff09<\/h3>\n<pre class=\"lang:default decode:true\">&lt;!DOCTYPE HTML&gt;\r\n&lt;html xmlns:th=\"http:\/\/www.thymeleaf.org\"&gt;\r\n&lt;head&gt;\r\n    &lt;title&gt;Hello World!&lt;\/title&gt;\r\n    &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\" \/&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;span th:text=\"${person.LastName}+${person.firstName}\"&gt;&lt;\/span&gt;\u3055\u3093\r\n    &lt;p th:text=\"${hello}\" \/&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u30dd\u30a4\u30f3\u30c8\u3068\u3057\u3066\u306f\u3001\u7d50\u679c\u30d3\u30e5\u30fc\u306b\u3066\u3001<span style=\"color: #ff0000;\"><strong>\u300cBean\u306e\u5909\u6570\u540d.\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u300d<\/strong><\/span>\u3068\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306f\u3001\u5fc5\u305a\u30d3\u30e5\u30fc\u3067\u53d6\u308a\u305f\u3044\u30e1\u30bd\u30c3\u30c9\u306b\u306fGetter\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\u7528\u610f\u3057\u306a\u3044\u3068\u52d5\u304b\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>\u300cBean\u306e\u5909\u6570\u540d.\u30d5\u30a3\u30fc\u30eb\u30c9\u540d\u300d\u306f\u3001\u6697\u9ed9\u7684\u306b\u300cBean\u306e\u5909\u6570\u540d.getName()\u300d\u306e\u3088\u3046\u306b\u5909\u63db\u3057\u3066\u5b9f\u884c\u3057\u305f\u7d50\u679c\u3092\u8868\u793a\u3055\u305b\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002<\/strong><\/span><\/p>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2939\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2018\/05\/HelloWorld.png\" alt=\"\" width=\"288\" height=\"129\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"\u4e0b\u8a18\u306e\u8a18\u4e8b\u306b\u3066\u3001\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5\uff09\u300d\u3067\u5024\u3092\u6e21\u3057\u3066\u3001\u753b\u9762\u306b\u8868\u793a\u3059\u308b\u624b\u9806\u3084\u30b5\u30f3\u30d7\u30eb\u3092\u3054\u7d39\u4ecb\u3055\u305b\u3066\u9802\u304d\u307e\u3057\u305f\u3002 \u3010Spring Boot\u3011\u300cThymeleaf(\u30bf\u30a4\u30e0\u30ea\u30fc\u30d5)\u300d\u3067\u30d3\u30e5\u30fc\u3092\u4f5c\u308d\u3046\u3002(Hello  [&hellip;]","protected":false},"author":1,"featured_media":2941,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2935"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2935"}],"version-history":[{"count":5,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2935\/revisions"}],"predecessor-version":[{"id":20567,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2935\/revisions\/20567"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/2941"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2935"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}