{"id":63,"date":"2019-11-28T13:23:49","date_gmt":"2019-11-28T04:23:49","guid":{"rendered":"http:\/\/kpc2019.satoshis.jp\/?p=63"},"modified":"2019-11-28T16:23:26","modified_gmt":"2019-11-28T07:23:26","slug":"%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%b3%e3%81%a8%e3%83%87%e3%83%bc%e3%82%bf%e3%83%99%e3%83%bc%e3%82%b9%e3%81%ae%e5%88%a9%e7%94%a8","status":"publish","type":"post","link":"https:\/\/kpc2019.satoshis.jp\/?p=63","title":{"rendered":"\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5229\u7528"},"content":{"rendered":"<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306eThymeleaf\u3068\u3001HSQLDB\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3046\u305f\u3081\u306bpom.xml\u306b\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;project xmlns=&quot;http:\/\/maven.apache.org\/POM\/4.0.0&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\r\n\txsi:schemaLocation=&quot;http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd&quot;&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\t&lt;parent&gt;\r\n\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t&lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\r\n\t\t&lt;version&gt;2.2.1.RELEASE&lt;\/version&gt;\r\n\t\t&lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\r\n\t&lt;\/parent&gt;\r\n\t&lt;groupId&gt;com.example&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;demo&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;name&gt;demo&lt;\/name&gt;\r\n\t&lt;description&gt;Demo project for Spring Boot&lt;\/description&gt;\r\n\r\n\t&lt;properties&gt;\r\n\t\t&lt;java.version&gt;1.8&lt;\/java.version&gt;\r\n\t&lt;\/properties&gt;\r\n\r\n\t&lt;dependencies&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\r\n\t\t\t&lt;scope&gt;test&lt;\/scope&gt;\r\n\t\t\t&lt;exclusions&gt;\r\n\t\t\t\t&lt;exclusion&gt;\r\n\t\t\t\t\t&lt;groupId&gt;org.junit.vintage&lt;\/groupId&gt;\r\n\t\t\t\t\t&lt;artifactId&gt;junit-vintage-engine&lt;\/artifactId&gt;\r\n\t\t\t\t&lt;\/exclusion&gt;\r\n\t\t\t&lt;\/exclusions&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.hsqldb&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;hsqldb&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t\r\n\t&lt;\/dependencies&gt;\r\n\r\n\t&lt;build&gt;\r\n\t\t&lt;plugins&gt;\r\n\t\t\t&lt;plugin&gt;\r\n\t\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t\t&lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\r\n\t\t\t&lt;\/plugin&gt;\r\n\t\t&lt;\/plugins&gt;\r\n\t&lt;\/build&gt;\r\n\r\n&lt;\/project&gt;\r\n<\/pre>\n<h3>\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u306e\u3084\u308a\u3068\u308a\u3092\u884c\u3046<\/h3>\n<p>form1.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;title&gt;\u5165\u529b\u30d5\u30a9\u30fc\u30e0&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form1&lt;\/h1&gt;\r\n&lt;p th:text=&quot;${msg}&quot;&gt;&lt;\/p&gt;\r\n&lt;form action=&quot;\/form1&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048\uff1a&lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t\u8a55\u4fa1\uff1a&lt;input type=&quot;text&quot; name=&quot;eval&quot; \/&gt;\r\n\t&lt;input type=&quot;submit&quot; value=&quot;Click!&quot; \/&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>IndexController.java \u306b form1 \u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [18,19,20,21,22,23,24,25,26,27,28,29,30,31]; title: ; notranslate\" title=\"\">\r\npackage com.example.demo;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\nimport org.springframework.web.bind.annotation.RequestParam;\r\nimport org.springframework.web.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class IndexConroller {\r\n\t@RequestMapping(&quot;\/test&quot;)\r\n\tpublic ModelAndView index(ModelAndView model) {\r\n\t\tmodel.setViewName(&quot;index&quot;);\r\n\t\tmodel.addObject(&quot;msg&quot;, &quot;\u30b5\u30fc\u30d0\u30fc\u3067\u8a2d\u5b9a\u3057\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u3059\u3088&quot;);\r\n\t\treturn model;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView model) {\r\n\t\tmodel.setViewName(&quot;form1&quot;);\r\n\t\treturn model;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView form1(ModelAndView model,\r\n\t\t\t@RequestParam(&quot;name&quot;) String name,\r\n\t\t\t@RequestParam(&quot;eval&quot;) String eval) {\r\n\t\tmodel.setViewName(&quot;form1&quot;);\r\n\t\tint percent = (name + eval).hashCode() % 101;\r\n\t\tpercent = Math.abs(percent);\r\n\t\tString result = name + &quot; \u3055\u3093\u306e &quot; + eval + &quot; \u5ea6\u306f&quot; + percent + &quot;%\u3067\u3059\u3002&quot;;\r\n\t\tmodel.addObject(&quot;msg&quot;, result);\r\n\t\treturn model;\r\n\t}\r\n}\r\n<\/pre>\n<h3>th:each \u3092\u4f7f\u3063\u3066\u8907\u6570\u306e\u8981\u7d20\u3092\u8868\u793a\u3059\u308b<\/h3>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306bList\u3092\u7528\u610f\u3057\u3066\u904e\u53bb\u306e\u5185\u5bb9\u3092\u4fdd\u5b58\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002<br \/>\n\u307e\u305f\u3001List\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u6e21\u3059\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [14,37,39]; title: ; notranslate\" title=\"\">\r\npackage com.example.demo;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RequestMethod;\r\nimport org.springframework.web.bind.annotation.RequestParam;\r\nimport org.springframework.web.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class IndexConroller {\r\n\tprivate List&lt;String&gt; list = new ArrayList&lt;&gt;();\r\n\r\n\t@RequestMapping(&quot;\/test&quot;)\r\n\tpublic ModelAndView index(ModelAndView model) {\r\n\t\tmodel.setViewName(&quot;index&quot;);\r\n\t\tmodel.addObject(&quot;msg&quot;, &quot;\u30b5\u30fc\u30d0\u30fc\u3067\u8a2d\u5b9a\u3057\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u3059\u3088&quot;);\r\n\t\treturn model;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView model) {\r\n\t\tmodel.setViewName(&quot;form1&quot;);\r\n\t\treturn model;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView form1(ModelAndView model,\r\n\t\t\t@RequestParam(&quot;name&quot;) String name,\r\n\t\t\t@RequestParam(&quot;eval&quot;) String eval) {\r\n\t\tmodel.setViewName(&quot;form1&quot;);\r\n\t\tint percent = (name + eval).hashCode() % 101;\r\n\t\tpercent = Math.abs(percent);\r\n\t\tString result = name + &quot; \u3055\u3093\u306e &quot; + eval + &quot; \u5ea6\u306f&quot; + percent + &quot;%\u3067\u3059\u3002&quot;;\r\n\t\tlist.add(result);\r\n\t\tmodel.addObject(&quot;msg&quot;, result);\r\n\t\tmodel.addObject(&quot;list&quot;, list);\r\n\t\treturn model;\r\n\t}\r\n}\r\n<\/pre>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b th:each \u3092\u8ffd\u52a0\u3057\u3066\u8907\u6570\u306e\u8981\u7d20\u3092\u8868\u793a\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [18,19,20,21,22,23,24]; 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;title&gt;\u5165\u529b\u30d5\u30a9\u30fc\u30e0&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form1&lt;\/h1&gt;\r\n&lt;p th:text=&quot;${msg}&quot;&gt;&lt;\/p&gt;\r\n&lt;form action=&quot;\/form1&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048\uff1a&lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t\u8a55\u4fa1\uff1a&lt;input type=&quot;text&quot; name=&quot;eval&quot; \/&gt;\r\n\t&lt;input type=&quot;submit&quot; value=&quot;Click!&quot; \/&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;hr \/&gt;\r\n\r\n&lt;table&gt;\r\n  &lt;tr th:each=&quot;obj : ${list}&quot;&gt;\r\n    &lt;td th:text=&quot;${obj}&quot;&gt;&lt;\/td&gt;\r\n  &lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3>\u8a3a\u65ad\u3092\u8ffd\u52a0\u3057\u3066\u307f\u308b<\/h3>\n<p>IndexController\u306e\u8ffd\u52a0<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(value=&quot;\/form2&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form2(ModelAndView model) {\r\n\t\tmodel.setViewName(&quot;form2&quot;);\r\n\t\treturn model;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form2&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView result(ModelAndView model,\r\n\t\t\t@RequestParam(&quot;name&quot;) String name) {\r\n\t\tString&#x5B;] s = {&quot;\u512a\u3057\u3055&quot;, &quot;\u51b7\u305f\u3055&quot;, &quot;\u9762\u767d\u3055&quot;, &quot;\u71b1\u8840\u3055&quot;, &quot;\u51b7\u9759\u3055&quot;,\r\n\t\t\t\t\t  &quot;\u771f\u9762\u76ee\u3055&quot;, &quot;\u53ef\u611b\u3055&quot;, &quot;\u7d20\u76f4\u3055&quot;, &quot;\u660e\u308b\u3055&quot;, &quot;\u8cac\u4efb\u611f&quot; };\r\n\t\tStringBuilder sb = new StringBuilder();\r\n\t\tsb.append(name).append(&quot; \u3055\u3093\u3002\u3002\u3002&quot;).append(&quot;&lt;br \/&gt;&quot;);\r\n\t\tfor (String t : s) {\r\n\t\t\tint percent = (name + t).hashCode() % 101;\r\n\t\t\tpercent = Math.abs(percent);\r\n\t\t\tsb.append(t).append(&quot; ... &quot;);\r\n\t\t\tsb.append(percent).append(&quot;%&quot;).append(&quot;&lt;br \/&gt;&quot;);\r\n\t\t}\r\n\t\tmodel.addObject(&quot;msg&quot;, sb.toString());\r\n\t\tmodel.setViewName(&quot;form2&quot;);\r\n\t\treturn model;\r\n\t}\r\n<\/pre>\n<p>form2.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;title&gt;\u5165\u529b\u30d5\u30a9\u30fc\u30e0&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form2&lt;\/h1&gt;\r\n&lt;form action=&quot;\/form2&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048\uff1a&lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t&lt;input type=&quot;submit&quot; value=&quot;\u8a3a\u65ad&quot; \/&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;hr \/&gt;\r\n&lt;p th:utext=&quot;${msg}&quot;&gt;&lt;\/p&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306eThymeleaf\u3068\u3001HSQLDB\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u3046\u305f\u3081\u306bpom.xml\u306b\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3002 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8 &hellip; <a href=\"https:\/\/kpc2019.satoshis.jp\/?p=63\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5229\u7528&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"views":480,"_links":{"self":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=63"}],"version-history":[{"count":6,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":69,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions\/69"}],"wp:attachment":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}