{"id":116,"date":"2019-06-04T10:01:43","date_gmt":"2019-06-04T01:01:43","guid":{"rendered":"http:\/\/2019se3.satoshis.jp\/?p=116"},"modified":"2019-06-04T12:49:52","modified_gmt":"2019-06-04T03:49:52","slug":"6%e6%9c%884%e6%97%a5","status":"publish","type":"post","link":"https:\/\/2019se3.satoshis.jp\/?p=116","title":{"rendered":"6\u67084\u65e5"},"content":{"rendered":"<h3>ModelAndView\u30af\u30e9\u30b9\u306e\u5229\u7528<\/h3>\n<p>ModelAndView\u30af\u30e9\u30b9\u306f\u3001\u30c7\u30fc\u30bf\u3068\u30d3\u30e5\u30fc\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u307e\u3068\u3081\u3066\u7ba1\u7406\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [22,23,24,25,26,27,28,29,30,31]; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.Model;\r\nimport org.springframework.web.bind.annotation.PathVariable;\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\r\n\t@RequestMapping(&quot;\/index\/{num}&quot;)\r\n\tpublic String index(@PathVariable int num, Model model) {\r\n\t\tint res = 0;\r\n\t\tfor (int i = 1; i &lt;= num; i++) {\r\n\t\t\tres += i;\r\n\t\t}\r\n\t\tmodel.addAttribute(&quot;msg&quot;, &quot;total: &quot; + res);\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(&quot;\/mav\/{num}&quot;)\r\n\tpublic ModelAndView mav(@PathVariable int num, ModelAndView mav) {\r\n\t\tint res = 0;\r\n\t\tfor (int i = 1; i &lt;= num; i++) {\r\n\t\t\tres += i;\r\n\t\t}\r\n\t\tmav.addObject(&quot;msg&quot;, &quot;total: &quot; + res);\r\n\t\tmav.setViewName(&quot;index&quot;);\r\n\t\treturn mav;\r\n\t}\r\n}\r\n<\/pre>\n<h3>\u30d5\u30a9\u30fc\u30e0\u3092\u5229\u7528\u3057\u305f\u30c7\u30fc\u30bf\u306e\u9001\u4fe1<\/h3>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u3001HTTP\u30e1\u30bd\u30c3\u30c9\u306eGET\u3068POST\u3092\u533a\u5225\u3057\u3066\u53d7\u4fe1\u3059\u308b\u3088\u3046\u306b\u3001\u305d\u308c\u305e\u308c\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<pre class=\"brush: java; highlight: [35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\r\n\r\nimport org.springframework.stereotype.Controller;\r\nimport org.springframework.ui.Model;\r\nimport org.springframework.web.bind.annotation.PathVariable;\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\r\n\t@RequestMapping(&quot;\/index\/{num}&quot;)\r\n\tpublic String index(@PathVariable int num, Model model) {\r\n\t\tint res = 0;\r\n\t\tfor (int i = 1; i &lt;= num; i++) {\r\n\t\t\tres += i;\r\n\t\t}\r\n\t\tmodel.addAttribute(&quot;msg&quot;, &quot;total: &quot; + res);\r\n\t\treturn &quot;index&quot;;\r\n\t}\r\n\r\n\t@RequestMapping(&quot;\/mav\/{num}&quot;)\r\n\tpublic ModelAndView mav(@PathVariable int num, ModelAndView mav) {\r\n\t\tint res = 0;\r\n\t\tfor (int i = 1; i &lt;= num; i++) {\r\n\t\t\tres += i;\r\n\t\t}\r\n\t\tmav.addObject(&quot;msg&quot;, &quot;total: &quot; + res);\r\n\t\tmav.setViewName(&quot;index&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form1(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form1&quot;);\r\n\t\tmav.addObject(&quot;msg&quot;, &quot;\u304a\u540d\u524d\u3092\u66f8\u3044\u3066\u9001\u4fe1\u3057\u3066\u304f\u3060\u3055\u3044&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView send(@RequestParam(&quot;text1&quot;)String str,\r\n\t\t\tModelAndView mav) {\r\n\t\tmav.addObject(&quot;msg&quot;, &quot;\u3053\u3093\u306b\u3061\u306f&quot; + str + &quot;\u3055\u3093\uff01&quot;);\r\n\t\tmav.addObject(&quot;value&quot;, str);\r\n\t\tmav.setViewName(&quot;form1&quot;);\r\n\t\treturn mav;\r\n\t}\r\n}\r\n<\/pre>\n<p>HTML\u3092\u7528\u610f\u3059\u308b\u3002<br \/>\n\u30c6\u30ad\u30b9\u30c8\u3067\u306findex.html\u3092\u4fee\u6b63\u3057\u3066\u518d\u5229\u7528\u3057\u3066\u3044\u308b\u304c\u3001\u3053\u3053\u3067\u306f\u65b0\u305f\u306bform1.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 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;top page&lt;\/title&gt;\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\n\th1 {\r\n\t\tfont-size: 18pt;\r\n\t\tfont-weight: bold;\r\n\t\tcolor: gray;\r\n\t}\r\n\tbody {\r\n\t\tfont-size: 13pt;\r\n\t\tcolor: gray;\r\n\t\tmargin: 5px 25px;\r\n\t}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form1&lt;\/h1&gt;\r\n\r\n&lt;p th:text=&quot;${msg}&quot;&gt;please wait...&lt;\/p&gt;\r\n&lt;form method=&quot;post&quot; action=&quot;\/form1&quot; &gt;\r\n\t&lt;input type=&quot;text&quot; name=&quot;text1&quot; th:value=&quot;${value}&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>\u8a3a\u65ad\u30e1\u30fc\u30ab\u30fc\u3063\u307d\u304f\u3057\u3066\u307f\u3088\u3046\uff01<\/p>\n<p>HTML\u306b\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; highlight: [24,25,26,27]; 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;top page&lt;\/title&gt;\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\n\th1 {\r\n\t\tfont-size: 18pt;\r\n\t\tfont-weight: bold;\r\n\t\tcolor: gray;\r\n\t}\r\n\tbody {\r\n\t\tfont-size: 13pt;\r\n\t\tcolor: gray;\r\n\t\tmargin: 5px 25px;\r\n\t}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form1&lt;\/h1&gt;\r\n\r\n&lt;p th:text=&quot;${msg}&quot;&gt;please wait...&lt;\/p&gt;\r\n&lt;p th:text=&quot;${result}&quot;&gt;please wait...&lt;\/p&gt;\r\n&lt;form method=&quot;post&quot; action=&quot;\/form1&quot; &gt;\r\n\t&lt;input type=&quot;text&quot; name=&quot;text1&quot; th:value=&quot;${value}&quot; \/&gt;&lt;br \/&gt;\r\n\t&lt;input type=&quot;text&quot; name=&quot;text2&quot; th:value=&quot;${text2}&quot; \/&gt;&lt;br \/&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>\u53d7\u3051\u53d6\u3063\u305f\u30c6\u30ad\u30b9\u30c8\u3067\u8a3a\u65ad\u3057\u3066\u7d50\u679c\u30920\uff5e100\uff05\u306e\u7bc4\u56f2\u3067\u8fd4\u3059\u3002<\/p>\n<pre class=\"brush: java; first-line: 42; title: ; notranslate\" title=\"\">\r\n\t@RequestMapping(value=&quot;\/form1&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView send(@RequestParam(&quot;text1&quot;)String str,\r\n\t\t\t@RequestParam(&quot;text2&quot;)String str2,\r\n\t\t\tModelAndView mav) {\r\n\t\tint p = (str + str2).hashCode() % 101;\r\n\t\tp = Math.abs(p);\r\n\t\tmav.addObject(&quot;msg&quot;, &quot;\u3053\u3093\u306b\u3061\u306f&quot; + str + &quot;\u3055\u3093\uff01&quot;);\r\n\t\tmav.addObject(&quot;result&quot;, str + &quot;\u3055\u3093\u306e&quot;\r\n\t\t\t\t\t\t\t+ str2 + &quot;\u5ea6\u306f\u3001&quot; + p +&quot;\uff05\u3067\u3059\u3002&quot;);\r\n\t\tmav.addObject(&quot;value&quot;, str);\r\n\t\tmav.addObject(&quot;text2&quot;, str2);\r\n\t\tmav.setViewName(&quot;form1&quot;);\r\n\t\treturn mav;\r\n\t}\r\n<\/pre>\n<p>\u8a3a\u65ad\u306e\u7d50\u679c\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n<p><img src=\"http:\/\/2019se3.satoshis.jp\/wp-content\/uploads\/2019\/06\/form1.png\" alt=\"\" width=\"400\" class=\"alignnone size-full wp-image-124\" srcset=\"https:\/\/2019se3.satoshis.jp\/wp-content\/uploads\/2019\/06\/form1.png 627w, https:\/\/2019se3.satoshis.jp\/wp-content\/uploads\/2019\/06\/form1-300x249.png 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<h3>\u305d\u306e\u307b\u304b\u306e\u30d5\u30a9\u30fc\u30e0\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb<\/h3>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304c\u9577\u304f\u306a\u3063\u3066\u304d\u305f\u306e\u3067\u3001\u65b0\u3057\u304f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<p>FormController<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.abc;\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 FormController {\r\n\t@RequestMapping(value=&quot;\/form2&quot;, method=RequestMethod.GET)\r\n\tpublic ModelAndView form2(ModelAndView mav) {\r\n\t\tmav.setViewName(&quot;form2&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n\t@RequestMapping(value=&quot;form2&quot;, method=RequestMethod.POST)\r\n\tpublic ModelAndView send(\r\n\t\t\t@RequestParam(value=&quot;check1&quot;, required=false)boolean check1,\r\n\t\t\t@RequestParam(value=&quot;radio1&quot;, required=false)String radio1,\r\n\t\t\t@RequestParam(value=&quot;select1&quot;, required=false)String select1,\r\n\t\t\t@RequestParam(value=&quot;select2&quot;, required=false)String[] select2,\r\n\t\t\tModelAndView mav) {\r\n\t\tString res = &quot;&quot;;\r\n\t\ttry {\r\n\t\t\tres= &quot;check1:&quot; + check1 +\r\n\t\t\t\t\t&quot; radio: &quot; + radio1 +\r\n\t\t\t\t\t&quot; select: &quot; + select1 +\r\n\t\t\t\t\t&quot;\\nselect2:&quot;;\r\n\t\t} catch (NullPointerException e) {}\r\n\t\ttry {\r\n\t\t\tres += select2[0];\r\n\t\t\tfor (int i = 1; i &lt; select2.length; i++) {\r\n\t\t\t\tres += &quot;, &quot; + select2[i];\r\n\t\t\t}\r\n\t\t} catch (NullPointerException e) {\r\n\t\t\tres += &quot;null&quot;;\r\n\t\t}\r\n\t\tmav.addObject(&quot;msg&quot;, res);\r\n\t\tmav.setViewName(&quot;form2&quot;);\r\n\t\treturn mav;\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>form2.html \u3092\u65b0\u898f\u4f5c\u6210\u3059\u308b\u3002<\/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;top page&lt;\/title&gt;\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\n\th1 {\r\n\t\tfont-size: 18pt;\r\n\t\tfont-weight: bold;\r\n\t\tcolor: gray;\r\n\t}\r\n\tbody {\r\n\t\tfont-size: 13pt;\r\n\t\tcolor: gray;\r\n\t\tmargin: 5px 25px;\r\n\t}\r\n\tpre {\r\n\t\tfont-size: 13pt;\r\n\t\tcolor: gray;\r\n\t\tpadding: 5px 10px;\r\n\t\tborder: 1px solid gray;\r\n\t}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;h1&gt;form2&lt;\/h1&gt;\r\n\r\n&lt;pre th:text=&quot;${msg}&quot;&gt;please wait...&lt;\/pre&gt;\r\n&lt;form method=&quot;post&quot; action=&quot;\/form2&quot; &gt;\r\n\t&lt;div&gt;\r\n\t&lt;input type=&quot;checkbox&quot; id=&quot;check1&quot; name=&quot;check1&quot; \/&gt;\r\n\t&lt;label for=&quot;check1&quot;&gt;\u30c1\u30a7\u30c3\u30af&lt;\/label&gt;\r\n\t&lt;\/div&gt;\r\n\t&lt;div&gt;\r\n\t&lt;input type=&quot;radio&quot; id=&quot;radioA&quot; name=&quot;radio1&quot; value=&quot;male&quot; \/&gt;\r\n\t&lt;label for=&quot;radioA&quot;&gt;\u7537\u6027&lt;\/label&gt;\r\n\t&lt;\/div&gt;\r\n\t&lt;div&gt;\r\n\t&lt;input type=&quot;radio&quot; id=&quot;radioB&quot; name=&quot;radio1&quot; value=&quot;female&quot; \/&gt;\r\n\t&lt;label for=&quot;radioB&quot;&gt;\u5973\u6027&lt;\/label&gt;\r\n\t&lt;\/div&gt;\r\n\t&lt;select id=&quot;select1&quot; name=&quot;select1&quot; size=&quot;4&quot;&gt;\r\n\t\t&lt;option value=&quot;Windows&quot;&gt;Windows&lt;\/option&gt;\r\n\t\t&lt;option value=&quot;Mac&quot;&gt;Mac&lt;\/option&gt;\r\n\t\t&lt;option value=&quot;Linux&quot;&gt;Linux&lt;\/option&gt;\r\n\t&lt;\/select&gt;\r\n\t&lt;select id=&quot;select2&quot; name=&quot;select2&quot; size=&quot;4&quot; multiple=&quot;multiple&quot;&gt;\r\n\t\t&lt;option value=&quot;Android&quot;&gt;Android&lt;\/option&gt;\r\n\t\t&lt;option value=&quot;iPhone&quot;&gt;iPhone&lt;\/option&gt;\r\n\t\t&lt;option value=&quot;winfone&quot;&gt;Windows Phone&lt;\/option&gt;\r\n\t&lt;\/select&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><img src=\"http:\/\/2019se3.satoshis.jp\/wp-content\/uploads\/2019\/06\/form2.png\" alt=\"\" width=\"400\" class=\"alignnone size-full wp-image-124\" \/><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>ModelAndView\u30af\u30e9\u30b9\u306e\u5229\u7528 ModelAndView\u30af\u30e9\u30b9\u306f\u3001\u30c7\u30fc\u30bf\u3068\u30d3\u30e5\u30fc\u306b\u95a2\u3059\u308b\u60c5\u5831\u3092\u307e\u3068\u3081\u3066\u7ba1\u7406\u3067\u304d\u308b\u3002 \u30d5\u30a9\u30fc\u30e0\u3092\u5229\u7528\u3057\u305f\u30c7\u30fc\u30bf\u306e\u9001\u4fe1 \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306f\u3001HTTP\u30e1\u30bd\u30c3\u30c9\u306eGET\u3068POST\u3092\u533a\u5225\u3057\u3066\u53d7\u4fe1\u3059 &hellip; <a href=\"https:\/\/2019se3.satoshis.jp\/?p=116\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;6\u67084\u65e5&#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":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/116"}],"collection":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=116"}],"version-history":[{"count":11,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2019se3.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}