{"id":385,"date":"2023-04-02T16:08:02","date_gmt":"2023-04-02T07:08:02","guid":{"rendered":"https:\/\/software.satoshis.jp\/?p=385"},"modified":"2023-04-17T15:47:47","modified_gmt":"2023-04-17T06:47:47","slug":"spring-boot%e3%81%aethymeleaf%e3%82%92%e5%9b%bd%e9%9a%9b%e5%8c%96%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/software.satoshis.jp\/?p=385","title":{"rendered":"Spring boot\u306ethymeleaf\u3092\u56fd\u969b\u5316\u3059\u308b"},"content":{"rendered":"<p>thymeleaf\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u56fd\u969b\u5316\u3059\u308b\u3084\u308a\u65b9\u3092\u307e\u3068\u3081\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u30e1\u30c3\u30bb\u30fc\u30b8\u30ea\u30bd\u30fc\u30b9\u3068\u306a\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002<br \/>\nsrc\/main\/resources \u306b i18n \u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u306b\u5404\u56fd\u8a9e\u5bfe\u5fdc\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u82f1\u8a9e\u3068\u65e5\u672c\u8a9e\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>src\/main\/resources\/i18n\/messages_en.properties<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nhelloworld=Hello World!\r\n<\/pre>\n<p>src\/main\/resources\/i18n\/messages_ja.properties<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nhelloworld=\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01\r\n<\/pre>\n<p>thymeleaf\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4e2d\u3067\u300chelloworld\u300d\u3092\u30ad\u30fc\u306b\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u30ea\u30bd\u30fc\u30b9\u304b\u3089\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>src\/main\/resources\/templates\/index.html<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html xmlns:th=&quot;http:\/\/www.thymeleaf.org&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;utf-8&quot;&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;h1 th:text=&quot;#{helloworld}&quot;&gt;Hello&lt;\/h1&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u73fe\u72b6\u3067\u306f\u3001thymeleaf \u306f\u30e1\u30c3\u30bb\u30fc\u30b8\u30ea\u30bd\u30fc\u30b9\u304c\u3069\u3053\u306b\u3042\u308b\u306e\u304b\u3092\u77e5\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u3069\u3053\u304b\u3067\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u3088\u3046\u306a\u8a2d\u5b9a\u306f\u3001applicationContext.xml\u306b\u8a18\u8ff0\u3059\u308b\u306e\u304c\u4e00\u822c\u7684\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>src\/main\/resources\/applicationContext.xml<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;beans xmlns=&quot;http:\/\/www.springframework.org\/schema\/beans&quot;\r\n       xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\r\n       xsi:schemaLocation=&quot;http:\/\/www.springframework.org\/schema\/beans\r\n           http:\/\/www.springframework.org\/schema\/beans\/spring-beans-2.5.xsd&quot;&gt;\r\n    &lt;bean id=&quot;messageSource&quot;\r\n        class=&quot;org.springframework.context.support.ResourceBundleMessageSource&quot;&gt;\r\n        &lt;property name=&quot;basenames&quot;&gt;\r\n            &lt;list&gt;\r\n                &lt;value&gt;i18n\/messages&lt;\/value&gt;\r\n            &lt;\/list&gt;\r\n        &lt;\/property&gt;\r\n    &lt;\/bean&gt;\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u8868\u793a\u3057\u3066\u304f\u308c\u308b\u304b\u3068\u601d\u3063\u305f\u3089\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f applicationContext.xml \u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304f\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002<br \/>\nmain\u30e1\u30bd\u30c3\u30c9\u3092\u66f8\u3044\u3066\u3044\u308b\u30af\u30e9\u30b9\u3067\u3001@ImportResource\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3057\u3066\u3084\u308c\u3070\u3044\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage hoge;\r\n\r\nimport org.springframework.boot.SpringApplication;\r\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\r\nimport org.springframework.context.annotation.ImportResource;\r\n\r\n@SpringBootApplication\r\n@ImportResource(&quot;classpath:applicationContext.xml&quot;)\r\npublic class HogeApplication {\r\n\r\n\tpublic static void main(String&#x5B;] args) {\r\n\t\tSpringApplication.run(HogeApplication.class, args);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>\u3053\u308c\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u56fd\u969b\u5316\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u30bf\u30b0\u306b th:text \u3067\u57cb\u3081\u8fbc\u3080\u65b9\u6cd5\u3067\u306f\u3001HTML\u30bf\u30b0\u306b\u9650\u3089\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>JavaScript\u5185\u306b\u3082\u56fd\u969b\u5316\u3057\u305f\u6587\u5b57\u5217\u3092\u57cb\u3081\u8fbc\u307f\u305f\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u969b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3002<br \/>\n\u30b3\u30e1\u30f3\u30c8\u5185\u3067\u57cb\u3081\u8fbc\u3080\u611f\u3058\u3067\u3059\u306d\u3002<br \/>\n\u3067\u3001\u30b3\u30e1\u30f3\u30c8\u76f4\u5f8c\u306e\u6570\u5024\u3084\u6587\u5b57\u306f\u3001\u57cb\u3081\u8fbc\u3093\u3060\u6587\u5b57\u5217\u3068\u7f6e\u304d\u63db\u3048\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nlet userId = \/*&#x5B;&#x5B;${user.id}]]*\/0;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>thymeleaf\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u56fd\u969b\u5316\u3059\u308b\u3084\u308a\u65b9\u3092\u307e\u3068\u3081\u3066\u304a\u304d\u307e\u3059\u3002 \u307e\u305a\u30e1\u30c3\u30bb\u30fc\u30b8\u30ea\u30bd\u30fc\u30b9\u3068\u306a\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u307e\u3059\u3002 src\/main\/resources \u306b i18n \u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u306b\u5404\u56fd &#8230; <\/p>\n","protected":false},"author":1,"featured_media":386,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[149,83,151,150],"class_list":["post-385","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-i18n","tag-spring-boot","tag-thymeleaf","tag-150"],"nelio_content":{"autoShareEndMode":"never","automationSources":{"useCustomSentences":false,"customSentences":[]},"efiAlt":"","efiUrl":"","followers":[1],"highlights":[],"isAutoShareEnabled":true,"networkImageIds":[],"permalinkQueryArgs":[],"series":[],"suggestedReferences":[]},"views":1589,"_links":{"self":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=385"}],"version-history":[{"count":4,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":398,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/385\/revisions\/398"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=\/wp\/v2\/media\/386"}],"wp:attachment":[{"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/software.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}