{"id":56,"date":"2020-11-05T15:13:07","date_gmt":"2020-11-05T06:13:07","guid":{"rendered":"http:\/\/kpc2020.satoshis.jp\/?p=56"},"modified":"2020-11-05T16:25:46","modified_gmt":"2020-11-05T07:25:46","slug":"spring-boot%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6web%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b-%e3%81%9d%e3%81%ae2","status":"publish","type":"post","link":"https:\/\/kpc2020.satoshis.jp\/?p=56","title":{"rendered":"Spring Boot\u3092\u4f7f\u3063\u3066Web\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3059\u308b \u305d\u306e2"},"content":{"rendered":"<p>IndexController\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\nsrc\/main\/java \u306e\u4e2d\u306b\u3042\u308b jp.kpc \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057[\u65b0\u898f]-[\u30af\u30e9\u30b9]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u540d\u524d\u306b\u300cIndexController\u300d\u3068\u5165\u529b\u3057\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p>SpringBoot \u306b\u5bfe\u3057\u3066\u3001\u3053\u306e\u30af\u30e9\u30b9\u304c\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u3042\u308b\u3053\u3068\u3092\u6559\u3048\u308b\u305f\u3081\u306b\u3001@Controller \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3002<br \/>\npublic class \u306e\u524d\u306e\u884c\u3067\u300c@Cont\u300d\u3092\u5165\u529b\u3057\u3066Ctrl+\u30b9\u30da\u30fc\u30b9\u3092\u5165\u529b\u3059\u308b\u3068\u5019\u88dc\u304c\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\u3055\u308c\u308b\u3002<br \/>\norg.springframework.stereotype \u306eController\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\n\r\n@Controller\r\npublic class IndexController {\r\n\t@RequestMapping(&quot;\/&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n}\r\n<\/pre>\n<p>SpringBoot\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8d77\u52d5\u3057\u3066\u3001 http:\/\/localhost:8080\/ \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u308b\u304c\u3001\u5148\u307b\u3069\u3068\u9055\u3046\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8aad\u3080\u3068\u3001index\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u3068\u3044\u3046\u610f\u5473\u306a\u306e\u3067\u3001\u6b21\u306f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>src\/main\/resources \u306e\u4e0b\u306b\u3042\u308b templates \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066[\u65b0\u898f]-[\u305d\u306e\u4ed6]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u300cHTML\u30d5\u30a1\u30a4\u30eb\u300d\u3092\u9078\u629e\u3057\u300c\u6b21\u3078\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u540d\u3092 index.html \u306b\u3057\u3066\u300c\u6b21\u3078\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<br \/>\n\u300c\u65b0\u898fHTML\u30d5\u30a1\u30a4\u30eb(5)\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p>\u3082\u3046\u3072\u3068\u3064URL\u306e\u30d1\u30b9\u3092\u5272\u308a\u5f53\u3066\u3066\u3001\u305d\u3061\u3089\u3067\u3082 index.html \u3092\u8868\u793a\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [14,15,16,17,18]; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class IndexController {\r\n\t@RequestMapping(&quot;\/&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(&quot;\/form&quot;)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;index&quot;);\r\n\t\treturn mav;\r\n\t}\r\n}\r\n<\/pre>\n<p>form.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;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/h1&gt;\r\n\r\n&lt;form action=&quot;\/form&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048: &lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t\u8a3a\u65ad: &lt;input type=&quot;text&quot; name=&quot;eval&quot; \/&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\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>IndexController \u306e form \u30e1\u30bd\u30c3\u30c9\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092 form \u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; first-line: 14; highlight: [16]; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(&quot;\/form&quot;)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n<\/pre>\n<p>form \u30e1\u30bd\u30c3\u30c9\u306f\u3001GET\u30e1\u30bd\u30c3\u30c9\u3060\u3051\u53d7\u3051\u4ed8\u3051\u308b\u3088\u3046\u306b\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; first-line: 15; highlight: [15]; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u3066\u518d\u8d77\u52d5\u3059\u308b\u3068\u3001http:\/\/localhost:8080\/form \u3078\u306e\u30a2\u30af\u30bb\u30b9\u306f\u4eca\u307e\u3067\u901a\u308a\u306b\u6b63\u5e38\u306b\u52d5\u4f5c\u3059\u308b\u304c\u3001\u300c\u8a3a\u65ad\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/kpc2020.satoshis.jp\/wp-content\/uploads\/2020\/10\/whitelabelerror405.png\" alt=\"\" width=\"670\" height=\"392\" class=\"alignnone size-full wp-image-49\" \/><\/p>\n<p>form \u30e1\u30bd\u30c3\u30c9\u3067GET\u30e1\u30bd\u30c3\u30c9\u3060\u3051\u3092\u53d7\u3051\u4ed8\u3051\u308b\u3088\u3046\u306b\u3057\u305f\u305f\u3081\u306b\u3001POST\u30e1\u30bd\u30c3\u30c9\u3092\u53d7\u3051\u53d6\u308b\u5834\u6240\u304c\u306a\u304f\u306a\u3063\u305f\u3002<\/p>\n<p>POST\u3092\u53d7\u3051\u53d6\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [21,22,23,24,25]; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\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.servlet.ModelAndView;\r\n\r\n@Controller\r\npublic class IndexController {\r\n\t@RequestMapping(&quot;\/&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView formPost(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>POST\u30e1\u30bd\u30c3\u30c9\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u3063\u3066\u3001\u7d50\u679c\u3092\u6e21\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"brush: java; first-line: 22; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView formPost(ModelAndView mav,\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\tString result = name + &quot; \u3055\u3093\u306e&quot; + eval + &quot;\u5ea6\u306f\uff1f&quot;;\r\n\t\tmav.addObject(&quot;result&quot;, result);\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n<\/pre>\n<p>form.html \u306b\u7d50\u679c\u3092\u8868\u793a\u3059\u308b\u30bf\u30b0\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [11]; 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;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/h1&gt;\r\n\r\n&lt;p th:text=&quot;${result}&quot;&gt;&lt;\/p&gt;\r\n\r\n&lt;form action=&quot;\/form&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048: &lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t\u8a3a\u65ad: &lt;input type=&quot;text&quot; name=&quot;eval&quot; \/&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\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u30d1\u30fc\u30bb\u30f3\u30c6\u30fc\u30b8\u3092\u8a08\u7b97\u3057\u3066\u7d50\u679c\u306b\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; first-line: 22; highlight: [26,27,28,29]; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView formPost(ModelAndView mav,\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\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\uff01\uff01\uff01&quot;;\r\n\t\tmav.addObject(&quot;result&quot;, result);\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n<\/pre>\n<p>\u904e\u53bb\u306e\u8a3a\u65ad\u7d50\u679c\u3082\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [14,34,36]; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\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 IndexController {\r\n\tprivate List&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\r\n\t@RequestMapping(&quot;\/&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView formPost(ModelAndView mav,\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\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\uff01\uff01\uff01&quot;;\r\n\t\tlist.add(result);\r\n\t\tmav.addObject(&quot;result&quot;, result);\r\n\t\tmav.addObject(&quot;list&quot;, list);\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<pre class=\"brush: xml; highlight: [22,23,24,25,26,27,28]; 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;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;\u8a3a\u65ad\u30da\u30fc\u30b8&lt;\/h1&gt;\r\n\r\n&lt;p th:text=&quot;${result}&quot;&gt;&lt;\/p&gt;\r\n\r\n&lt;form action=&quot;\/form&quot; method=&quot;post&quot;&gt;\r\n\t\u304a\u306a\u307e\u3048: &lt;input type=&quot;text&quot; name=&quot;name&quot; \/&gt;\r\n\t&lt;br \/&gt;\r\n\t\u8a3a\u65ad: &lt;input type=&quot;text&quot; name=&quot;eval&quot; \/&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\r\n&lt;h3&gt;\u3053\u308c\u307e\u3067\u306e\u8a3a\u65ad\u7d50\u679c&lt;\/h3&gt;\r\n\r\n&lt;table&gt;\r\n\t&lt;tr th:each=&quot;result : ${list}&quot;&gt;\r\n\t\t&lt;td th:text=&quot;${result}&quot;&gt;&lt;\/td&gt;\r\n\t&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u914d\u5e03\u30d5\u30a9\u30eb\u30c0\u306b\u3042\u308b hsqldb \u30d5\u30a9\u30eb\u30c0\u3092\u30b3\u30d4\u30fc\u3057\u3066Z\u30c9\u30e9\u30a4\u30d6\u306e\u9069\u5f53\u306a\u5834\u6240\u306b\u8cbc\u308a\u4ed8\u3051\u308b\u3002<br \/>\nhsqldb \u30d5\u30a9\u30eb\u30c0\u5185\u306e hsqldb.bat \u3092\u7de8\u96c6\u3059\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncd data\r\njava -classpath ..\/lib\/hsqldb.jar org.hsqldb.server.Server --database.0 db\/shindan --dbname.0 shindan\r\n<\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u306e\u63a5\u7d9a\u3092\u884c\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001pom.xml \u3092\u7de8\u96c6\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [42,43,44,45,46,47,48,49]; 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;jp.kpc&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;example&lt;\/artifactId&gt;\r\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;name&gt;example&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;11&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-thymeleaf&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&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\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\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&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<p>src\/main\/resources \u306b\u3042\u308b application.properties \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u3001\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nspring.datasource.url=jdbc:hsqldb:hsql:\/\/localhost\/shindan\r\nspring.datasource.username=SA\r\nspring.datasource.password=\r\nspring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver\r\n<\/pre>\n<p>jp.kpc \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066[\u65b0\u898f]-[\u30af\u30e9\u30b9]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u540d\u524d\u306b\u300cShindan\u300d\u3092\u5165\u529b\u3057\u3066\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u5165\u529b\u3059\u308b\u3002<br \/>\nEclipse\u304c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306e\u88dc\u5b8c\u3092\u3057\u3066\u304f\u308c\u306a\u3044\u5834\u5408\u306f\u3001pom.xml \u3092\u4fdd\u5b58\u3057\u3066\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067\u3001\u4fdd\u5b58\u3092\u78ba\u8a8d\uff01<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport javax.persistence.Column;\r\nimport javax.persistence.Entity;\r\nimport javax.persistence.GeneratedValue;\r\nimport javax.persistence.Id;\r\nimport javax.validation.constraints.NotEmpty;\r\nimport javax.validation.constraints.NotNull;\r\n\r\n@Entity\r\npublic class Shindan {\r\n\t@Id\r\n\t@GeneratedValue\r\n\t@Column\r\n\t@NotNull\r\n\tprivate long id;\r\n\r\n\t@Column\r\n\t@NotEmpty\r\n\tprivate String name;\r\n\r\n\t@Column\r\n\t@NotEmpty\r\n\tprivate String eval;\r\n\r\n\t@Column\r\n\t@NotNull\r\n\tprivate int percent;\r\n}\r\n<\/pre>\n<p>\u30e1\u30cb\u30e5\u30fc\u306e[\u30bd\u30fc\u30b9]-[getter\u304a\u3088\u3073setter\u306e\u751f\u6210]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u300c\u3059\u3079\u3066\u9078\u629e\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<br \/>\n\u633f\u5165\u30dd\u30a4\u30f3\u30c8\u306f\u300c\u6700\u5f8c\u306e\u30e1\u30f3\u30d0\u30fc\u300d\u3092\u9078\u629e\u3057\u3001\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p>\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306bgetter\/setter \u304c\u8ffd\u52a0\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport javax.persistence.Column;\r\nimport javax.persistence.Entity;\r\nimport javax.persistence.GeneratedValue;\r\nimport javax.persistence.Id;\r\nimport javax.validation.constraints.NotEmpty;\r\nimport javax.validation.constraints.NotNull;\r\n\r\n@Entity\r\npublic class Shindan {\r\n\t@Id\r\n\t@GeneratedValue\r\n\t@Column\r\n\t@NotNull\r\n\tprivate long id;\r\n\r\n\t@Column\r\n\t@NotEmpty\r\n\tprivate String name;\r\n\r\n\t@Column\r\n\t@NotEmpty\r\n\tprivate String eval;\r\n\r\n\t@Column\r\n\t@NotNull\r\n\tprivate int percent;\r\n\r\n\tpublic long getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(long id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\r\n\tpublic String getEval() {\r\n\t\treturn eval;\r\n\t}\r\n\r\n\tpublic void setEval(String eval) {\r\n\t\tthis.eval = eval;\r\n\t}\r\n\r\n\tpublic int getPercent() {\r\n\t\treturn percent;\r\n\t}\r\n\r\n\tpublic void setPercent(int percent) {\r\n\t\tthis.percent = percent;\r\n\t}\r\n}\r\n<\/pre>\n<p>jp.kpc \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066[\u65b0\u898f]-[\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u540d\u524d\u306b\u300cShindanRepository\u300d\u3092\u5165\u529b\u3002<br \/>\n\u62e1\u5f35\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u300c\u8ffd\u52a0\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<br \/>\nJapRepository \u3092\u9078\u629e\u3057\u3066\u300cOK\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<br \/>\n\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3044\u308b T \u3092 Shindan \u306b\u5909\u66f4\u3001ID \u3092 Long \u306b\u5909\u66f4\u3057\u3066\u4fdd\u5b58\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport org.springframework.data.jpa.repository.JpaRepository;\r\n\r\npublic interface ShindanRepository extends JpaRepository&lt;Shindan, Long&gt; {\r\n\r\n}\r\n<\/pre>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306bShindan\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [16,17,37,38,39,40,41]; title: ; notranslate\" title=\"\">\r\npackage jp.kpc;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\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 IndexController {\r\n\tprivate List&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\t@Autowired\r\n\tprivate ShindanRepository repository;\r\n\r\n\t@RequestMapping(&quot;\/&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView formPost(ModelAndView mav,\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\tint percent = (name + eval).hashCode() % 101;\r\n\t\tpercent = Math.abs(percent);\r\n\r\n\t\tShindan shindan = new Shindan();\r\n\t\tshindan.setName(name);\r\n\t\tshindan.setEval(eval);\r\n\t\tshindan.setPercent(percent);\r\n\t\trepository.saveAndFlush(shindan);\r\n\r\n\t\tString result = name + &quot; \u3055\u3093\u306e&quot; + eval + &quot;\u5ea6\u306f&quot; + percent + &quot;%\u3067\u3059\uff01\uff01\uff01&quot;;\r\n\t\tlist.add(result);\r\n\t\tmav.addObject(&quot;result&quot;, result);\r\n\t\tmav.addObject(&quot;list&quot;, list);\r\n\t\tmav.setViewName(&quot;form&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>\u8a3a\u65ad\u3092\u3072\u3068\u3064\u3084\u3063\u3066\u307f\u3066\u304b\u3089\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u3066\u307f\u308b\u3002<br \/>\nmanager.bat \u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<br \/>\nType\u3067\u300cHSQL Database Engine Server\u300d\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\nURL\u3092\u300cjdbc:hsqldb:hsql:\/\/localhost\/shindan\u300d\u306b\u3057\u3066\u300cOK\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/kpc2020.satoshis.jp\/wp-content\/uploads\/2020\/11\/hsqldb-connect.png\" alt=\"\" width=\"378\" height=\"424\" class=\"alignnone size-full wp-image-68\" \/><\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>IndexController\u3092\u4f5c\u6210\u3059\u308b\u3002 src\/main\/java \u306e\u4e2d\u306b\u3042\u308b jp.kpc \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057[\u65b0\u898f]-[\u30af\u30e9\u30b9]\u3092\u9078\u629e\u3059\u308b\u3002 \u540d\u524d\u306b\u300cIndexController\u300d\u3068\u5165\u529b\u3057\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002 Sp &hellip; <a href=\"https:\/\/kpc2020.satoshis.jp\/?p=56\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Spring Boot\u3092\u4f7f\u3063\u3066Web\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3059\u308b \u305d\u306e2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-java","category-springboot"],"views":183,"_links":{"self":[{"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/56","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=56"}],"version-history":[{"count":11,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/56\/revisions\/70"}],"wp:attachment":[{"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kpc2020.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}