{"id":51,"date":"2019-11-21T13:41:28","date_gmt":"2019-11-21T04:41:28","guid":{"rendered":"http:\/\/kpc2019.satoshis.jp\/?p=51"},"modified":"2019-11-21T16:14:29","modified_gmt":"2019-11-21T07:14:29","slug":"web%e3%82%a2%e3%83%97%e3%83%aa%e9%96%8b%e7%99%ba%ef%bc%88%e5%86%8d%e3%83%81%e3%83%a3%e3%83%ac%e3%83%b3%e3%82%b8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/kpc2019.satoshis.jp\/?p=51","title":{"rendered":"Web\u30a2\u30d7\u30ea\u958b\u767a\uff08\u518d\u30c1\u30e3\u30ec\u30f3\u30b8\uff09"},"content":{"rendered":"<p>\u30e1\u30cb\u30e5\u30fc\u304b\u3089[\u65b0\u898f]-[\u30d7\u30ed\u30b8\u30a7\u30af\u30c8]\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>SpringBoot\u306e\u4e2d\u306b\u3042\u308b\u300cSpring\u30b9\u30bf\u30fc\u30bf\u30fc\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\nWeb\u306e\u4e2d\u306b\u3042\u308b\u300cSpring Web\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u5b8c\u4e86\u300d\u3059\u308b\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u300cdemo\u300d\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066[Maven]-[\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u66f4\u65b0]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n \u300cOK\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u753b\u9762\u4e0b\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u30d0\u30fc\u306b\u4f55\u304b\u51e6\u7406\u304c\u52d5\u3044\u3066\u3044\u308b\u8868\u793a\u306b\u306a\u308b\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u66f4\u65b0\u304c\u7d42\u308f\u3063\u305f\u3089\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u300cdemo\u300d\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066[\u5b9f\u884c]-[maven install]\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u3044\u308d\u3044\u308d\u3068\u8868\u793a\u3055\u308c\u3001\u6700\u5f8c\u306e\u307b\u3046\u306b\u300cBUILD SUCCESS\u300d\u3068\u8868\u793a\u3055\u308c\u308c\u3070OK\uff01<\/p>\n<p>\u306a\u305c\u304b\u3001SpringBoot\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u8d77\u52d5\u3057\u3066\u3082\u52d5\u4f5c\u3057\u306a\u3044\u306e\u3067\u3001\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u3001\u5225\u306b\u6e96\u5099\u3057\u305fTomcat\u4e0a\u3067\u52d5\u4f5c\u3055\u305b\u3066\u307f\u308b\u3002<\/p>\n<p>demo \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u300c\u30d7\u30ed\u30d1\u30c6\u30a3\u300d\u3092\u9078\u629e\u3057\u3001\u5de6\u5074\u304b\u3089\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30fb\u30d5\u30a1\u30bb\u30c3\u30c8\u300d\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u56f3\u306e\u3088\u3046\u306b\u3001\u30c1\u30a7\u30c3\u30af\u3057\u305f\u72b6\u614b\u3067\u300c\u9069\u7528\u3057\u3066\u9589\u3058\u308b\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/kpc2019.satoshis.jp\/wp-content\/uploads\/2019\/11\/projectfacet1.png\" alt=\"\" width=\"1000\" height=\"690\" class=\"alignnone size-full wp-image-57\" \/><\/p>\n<p>demo \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u300c\u5b9f\u884c\u300d\u2010\u300cSpringBoot\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u300d\u3092\u9078\u629e\u3059\u308b\u3068Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<p>\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u300c Started DemoApplication in 2.426 seconds (JVM running for 2.933)\u300d\u306e\u3088\u3046\u306a\u8868\u793a\u304c\u51fa\u3066\u3044\u308c\u3070OK\u3002<\/p>\n<p>\u753b\u9762\u4e0a\u306b\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30fb\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u30fc\u300d\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u30e1\u30cb\u30e5\u30fc\u30d0\u30fc\u304b\u3089\u300c\u30a6\u30a3\u30f3\u30c9\u30a6\u300d\u2010\u300c\u30d1\u30fc\u30b9\u30da\u30af\u30c6\u30a3\u30d6\u300d\u2010\u300c\u30d1\u30fc\u30b9\u30da\u30af\u30c6\u30a3\u30d6\u3092\u958b\u304f\u300d\u2010\u300c\u305d\u306e\u4ed6\u300d\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>\u30d1\u30fc\u30b9\u30da\u30af\u30c6\u30a3\u30d6\u306e\u4e00\u89a7\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u300cJavaEE\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u958b\u304f\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<\/p>\n<h3>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u4f5c\u6210<\/h3>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30fb\u30a8\u30af\u30b9\u30d7\u30ed\u30fc\u30e9\u30fc\u3067\u300cJava\u30ea\u30bd\u30fc\u30b9\u300d\u2010\u300csrc\/main\/java\u300d-\u300ccom.example.demo\u300d\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u300c\u65b0\u898f\u300d\u2010\u300c\u30af\u30e9\u30b9\u300d\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>\u540d\u524d\u306b\u300cHelloController\u300d\u3068\u5165\u529b\u3057\u300c\u5b8c\u4e86\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p>http:\/\/localhost:8080\/hello \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u753b\u9762\u4e0a\u306b\u300cHello World!\u300d\u3068\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<h3>\u9759\u7684HTML\u30d5\u30a1\u30a4\u30eb\u306e\u8868\u793a<\/h3>\n<p>src\/main\/resource \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3066\u300c\u65b0\u898f\u300d\u2010\u300c\u30d5\u30a9\u30eb\u30c0\u300d\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u300cpublic\u300d\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>public \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u300c\u65b0\u898f\u300d\u2010\u300c\u305d\u306e\u4ed6\u300d\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u300cHTML\u30d5\u30a1\u30a4\u30eb\u300d\u3092\u9078\u629e\u3057\u3066 index.html \u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;title&gt;Hello index.html&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;style&gt;\r\nh1 {\r\n  color: red;\r\n}\r\ndiv.border {\r\n\tborder: solid 2px blue;\r\n\tborder-radius: 5px;\r\n\tpadding: 5px;\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;\r\n\r\n\r\n&lt;h1&gt;Hello&lt;\/h1&gt;\r\n&lt;p&gt;Hello index.html&lt;\/p&gt;\r\n\r\n&lt;div class=&quot;border&quot;&gt;\r\ndiv \u30bf\u30b0\u306b\u30dc\u30fc\u30c0\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u4f8b\r\n&lt;\/div&gt;\r\n\r\n&lt;hr \/&gt;\r\n\r\n&lt;p&gt;src\/main\/resources\/public\/index.html&lt;\/p&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>http:\/\/localhost:8080\/ \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001public\/index.html \u306e\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<h3>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3068\u30d3\u30e5\u30fc\u306e\u5229\u7528<\/h3>\n<p>\u4eca\u56de\u306f\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e0d\u8db3\u306e\u305f\u3081\u306b\u52d5\u4f5c\u3057\u306a\u3044\u304c\u3001SpringBoot\u306e\u5834\u5408\u3001Controller\u3068View\u3092\u7d44\u307f\u5408\u308f\u305b\u3066Web\u30b5\u30a4\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>src\/main\/java \u306e com.example.demo \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u300c\u65b0\u898f\u300d\u2010\u300c\u30af\u30e9\u30b9\u300d\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>\/test \u3068\u3044\u3046URL\u306b\u30a2\u30af\u30bb\u30b9\u304c\u6765\u305f\u3089\u3001templates\/index.html \u3092\u8868\u793a\u3059\u308b\u4ed5\u7d44\u307f\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>IndexController.java<\/p>\n<pre class=\"brush: java; 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\n\r\n@Controller\r\npublic class IndexConroller {\r\n\t@RequestMapping(&quot;\/test&quot;)\r\n\tpublic String index() {\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n}\r\n<\/pre>\n<p>src\/main\/resources \u306e temlates \u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u300c\u65b0\u898f\u300d\u2010\u300c\u305d\u306e\u4ed6\u300d\u3092\u9078\u629e\u3059\u308b\u3002<br \/>\n\u300cHTML\u30d5\u30a1\u30a4\u30eb\u300d\u3092\u9078\u629e\u3057\u3001 index.html \u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;title&gt;Controller test&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\nHello src\/main\/resources\/templates\/index.html\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3>\u30b5\u30fc\u30d0\u30fc\u306b\u30c7\u30fc\u30bf\u3092\u554f\u3044\u5408\u308f\u305b\u308b<\/h3>\n<p>Beer \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>Beer.java<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage com.example.demo;\r\n\r\npublic class Beer {\r\n\tprivate String name;\r\n\tprivate int price;\r\n\tpublic Beer(String name, int price) {\r\n\t\tthis.name = name;\r\n\t\tthis.price = price;\r\n\t}\r\n\tpublic String getName() {\r\n\t\treturn name;\r\n\t}\r\n\tpublic void setName(String name) {\r\n\t\tthis.name = name;\r\n\t}\r\n\tpublic int getPrice() {\r\n\t\treturn price;\r\n\t}\r\n\tpublic void setPrice(int price) {\r\n\t\tthis.price = price;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>\u30d3\u30fc\u30eb\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3059\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; 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.web.bind.annotation.RequestMapping;\r\nimport org.springframework.web.bind.annotation.RestController;\r\n\r\n@RestController\r\npublic class BeerController {\r\n\t@RequestMapping(&quot;\/beer&quot;)\r\n\tpublic List&lt;Beer&gt; beers() {\r\n\t\tList&lt;Beer&gt; list = new ArrayList&lt;&gt;();\r\n\t\tlist.add(new Beer(&quot;\u4e00\u756a\u643e\u308a&quot;, 200));\r\n\t\tlist.add(new Beer(&quot;\u30d7\u30ec\u30df\u30a2\u30e0\u30e2\u30eb\u30c4&quot;, 240));\r\n\t\tlist.add(new Beer(&quot;\u30ae\u30cd\u30b9&quot;, 300));\r\n\t\treturn list;\r\n\t}\r\n}\r\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067JSON\u30c7\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3001AJAX\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u3057\u3001\u753b\u9762\u3092\u66f4\u65b0\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;UTF-8&quot;&gt;\r\n&lt;title&gt;Hello index.html&lt;\/title&gt;\r\n&lt;script src=&quot;jquery-1.12.4.min.js&quot;&gt;&lt;\/script&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n$.ajax({\r\n\turl: '\/beer',\r\n\tdataType: 'json',\r\n\tsuccess: function(data) {\r\n\t\tresult(data);\r\n\t}\r\n});\r\n\r\nfunction result(data) {\r\n\tvar div = $('#beers');\r\n\t$.each(data, function(i) {\r\n\t\tconsole.log(data&#x5B;i]);\r\n\t\tvar beer = $('&lt;div&gt;');\r\n\t\tvar name = $('&lt;span&gt;').text(data&#x5B;i].name);\r\n\t\tvar price = $('&lt;span&gt;').text(data&#x5B;i].price + '\u5186');\r\n\t\tbeer.append(name);\r\n\t\tbeer.append(price);\r\n\t\tdiv.append(beer);\r\n\t});\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;style&gt;\r\nh1 {\r\n  color: red;\r\n}\r\ndiv.border {\r\n\tborder: solid 2px blue;\r\n\tborder-radius: 5px;\r\n\tpadding: 5px;\r\n}\r\n&lt;\/style&gt;\r\n&lt;body&gt;\r\n\r\n\r\n&lt;h1&gt;Hello&lt;\/h1&gt;\r\n&lt;p&gt;Hello index.html&lt;\/p&gt;\r\n\r\n&lt;div class=&quot;border&quot;&gt;\r\ndiv \u30bf\u30b0\u306b\u30dc\u30fc\u30c0\u30fc\u3092\u8ffd\u52a0\u3059\u308b\u4f8b\r\n&lt;\/div&gt;\r\n\r\n&lt;div id=&quot;beers&quot;&gt;&lt;\/div&gt;\r\n\r\n&lt;hr \/&gt;\r\n\r\n&lt;p&gt;src\/main\/resources\/public\/index.html&lt;\/p&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30e1\u30cb\u30e5\u30fc\u304b\u3089[\u65b0\u898f]-[\u30d7\u30ed\u30b8\u30a7\u30af\u30c8]\u3092\u9078\u629e\u3059\u308b\u3002 SpringBoot\u306e\u4e2d\u306b\u3042\u308b\u300cSpring\u30b9\u30bf\u30fc\u30bf\u30fc\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u300d\u3092\u9078\u629e\u3059\u308b\u3002 Web\u306e\u4e2d\u306b\u3042\u308b\u300cSpring Web\u300d\u3092\u9078\u629e\u3057\u3066\u300c\u5b8c\u4e86\u300d\u3059\u308b\u3002 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u300cde &hellip; <a href=\"https:\/\/kpc2019.satoshis.jp\/?p=51\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Web\u30a2\u30d7\u30ea\u958b\u767a\uff08\u518d\u30c1\u30e3\u30ec\u30f3\u30b8\uff09&#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-51","post","type-post","status-publish","format-standard","hentry","category-spring-boot"],"views":674,"_links":{"self":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/51","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=51"}],"version-history":[{"count":8,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions\/61"}],"wp:attachment":[{"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kpc2019.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}