{"id":448,"date":"2017-08-02T16:00:56","date_gmt":"2017-08-02T16:00:56","guid":{"rendered":"http:\/\/happily70.dothome.co.kr\/?p=448"},"modified":"2017-08-02T16:00:56","modified_gmt":"2017-08-02T16:00:56","slug":"requestbody-responsebody","status":"publish","type":"post","link":"http:\/\/happily70.dothome.co.kr\/?p=448","title":{"rendered":"@RequestBody \/ @ResponseBody"},"content":{"rendered":"<p>@RequestBody : HTTP \uc694\uccad\uc758 body \ub0b4\uc6a9\uc744 \uc790\ubc14 \uac1d\uccb4\ub85c \ub9e4\ud551\ud55c\ub2e4.<\/p>\n<p>@ResponseBody : \uc790\ubc14 \uac1d\uccb4\ub97c HTTP \uc694\uccad\uc758 body\ub85c \ub9e4\ud551\ud55c\ub2e4.<\/p>\n<p>\uc608\uc81c :\u00a0test.jsp<\/p>\n<pre class=\"prettyprint\">function test(){\r\n        var rowData = $(\"#main_grid\").getRowData();    \r\n      \r\n        var json = JSON.stringify(rowData) ;\r\n        var jsonInfo = JSON.parse(json) ;\r\n   \r\n        var actionUrl = \"\/test\/testList.do\";\r\n         \r\n \r\n       \r\n            $.ajax({\r\n                type:\"POST\",\r\n                dataType : 'json',\r\n                data : json,\r\n                url: actionUrl,\r\n                processData : true \/*querySTring make false*\/,\r\n                contentType : \"application\/json; charset=UTF-8\",             \r\n                \r\n                success:function(result) {\r\n                    var jsonResult = JSON.parse(JSON.stringify(result)) ;\r\n                     \r\n                    if(jsonResult.result == \"success\" ) {\r\n                        alert(jsonResult.resultMsg) ;                        \r\n                          \r\n                    } else if (jsonResult.result == \"failure\" ) {\r\n                        alert(jsonResult.resultMsg) ;\r\n                        return false ;\r\n                    }\r\n                },\r\n                complete : function () {\r\n                },               \r\n                error: AjaxError\r\n            }) ;\r\n       \r\n     } else {\r\n            return false;\r\n        }       \r\n    }\r\n<\/pre>\n<p>$(&#8220;#main_grid&#8221;) \ub77c\ub294 jqGrid\uc5d0\uc11c getRowData()\ub97c \ud1b5\ud574 \uc804\uccb4 Row\ub97c \uac00\uc838\uc654\ub2e4.<br \/>\n\uadf8 \ud6c4 Json\ud615\uc2dd\uc73c\ub85c \ubcc0\ud658\ud55c \ub4a4 \ud30c\ub77c\ubbf8\ud130\ub85c \ub358\uc838\uc8fc\uc5c8\ub2e4.<\/p>\n<p>test.java<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"prettyprint\">\r\n@RequestMapping(\"\/test\/testList.do\")\r\n @ResponseBody\r\n public Object testList(HttpServletRequest request, @RequestBody List<Map<String, Object>> list) throws Exception {\r\n  Map <String, String> resultMap =  new HashMap<String, String>();\r\n   \r\n  String result = \"\";\r\n  String resultMsg = \"\";\r\n   \r\n  try {  \r\n   for(Map<String, Object> tList : list) {\r\n    aVO authVO = new AuthVO() ;\r\n     \r\n    aVO.setUse_auth(tList.get(\"use_auth\").toString());\r\n    aVO.setMenu_id(tList.get(\"menu_id\").toString());\r\n    aVO.setUse_yn(tList.get(\"use_yn\").toString());\r\n \r\n    authMgmtService.mergeAuthMgmtList(aVO) ;\r\n   }\r\n    \r\n   result = \"success\";\r\n   resultMsg = \"\uc131\uacf5\" ;\r\n    \r\n  } catch (Exception e) {\r\n   result = \"failure\";\r\n   resultMsg = \"\uc2e4\ud328\" ;\r\n  }\r\n   \r\n  resultMap.put(\"result\", result);\r\n  resultMap.put(\"resultMsg\", resultMsg);\r\n   \r\n  return resultMap;\r\n }\r\n<\/pre>\n<p>\uc804\uc1a1 \ub41c \ud30c\ub77c\ubbf8\ud130\ub97c List<Map<String, Object>> \ud615\uc2dd\uc73c\ub85c \ubc1b\uc544\uc628\ub2e4. \uc55e\uc5d0 @RequestBody\ub97c \uc4f0\uba74 \uadf8\ub300\ub85c list\uc5d0 \ub9e4\ud551\ub418\uc5b4\uc9c4\ub2e4.<br \/>\n\uadf8\ub9ac\uace0 list\uc758 size\ub9cc\ud07c for\ubb38\uc744 \uc2e4\ud589\ud558\ub294\ub370 aVo\ub77c\ub294 vo\uac1d\uccb4\ub97c \ud558\ub098 \uc0dd\uc131\ud574\uc11c list\uc5d0\uc11c \ubc1b\uc544\uc628 map\uc758 value\uac12\uc744 \ub123\uc5b4\uc900\ub2e4.<br \/>\n\uc791\uc5c5\uc744 \uc218\ud589\ud55c \ub4a4 result\uc640 resultMsg\ub97c resultMap\uc5d0 \ub2f4\uc544 \ub9ac\ud134\ud55c\ub2e4. @ResponseBody\ub97c \uba85\uc2dc\ud588\uae30 \ub54c\ubb38\uc5d0 \uc751\ub2f5\ub370\uc774\ud130\uc5d0 Map\uac1d\uccb4\uac00 \ub9e4\ud551\ub418\uc5b4 \uc804\ub2ec\ub41c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>@RequestBody : HTTP \uc694\uccad\uc758 body \ub0b4\uc6a9\uc744 \uc790\ubc14 \uac1d\uccb4\ub85c \ub9e4\ud551\ud55c\ub2e4. @ResponseBody : \uc790\ubc14 \uac1d\uccb4\ub97c HTTP \uc694\uccad\uc758 body\ub85c \ub9e4\ud551\ud55c\ub2e4. \uc608\uc81c :\u00a0test.jsp function test(){ var rowData = $(&#8220;#main_grid&#8221;).getRowData(); var json = JSON.stringify(rowData) ; var jsonInfo = JSON.parse(json) ; var actionUrl = &#8220;\/test\/testList.do&#8221;; $.ajax({ type:&#8221;POST&#8221;, dataType : &#8216;json&#8217;, data : json, url: actionUrl, processData : true \/*querySTring make false*\/,<\/p>\n<footer class=\"entry-footer index-entry\">\n<div class=\"post-social pull-left\"><a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=http%3A%2F%2Fhappily70.dothome.co.kr%2F%3Fp%3D448\" target=\"_blank\" class=\"social-icons\"><i class=\"fa fa-facebook\" aria-hidden=\"true\"><\/i><\/a><a href=\"https:\/\/twitter.com\/home?status=http%3A%2F%2Fhappily70.dothome.co.kr%2F%3Fp%3D448\" target=\"_blank\" class=\"social-icons\"><i class=\"fa fa-twitter\" aria-hidden=\"true\"><\/i><\/a><a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=http%3A%2F%2Fhappily70.dothome.co.kr%2F%3Fp%3D448&#038;title=%40RequestBody+%2F+%40ResponseBody\" target=\"_blank\" class=\"social-icons\"><i class=\"fa fa-linkedin\" aria-hidden=\"true\"><\/i><\/a><\/div>\n<p class=\"link-more\"><a href=\"http:\/\/happily70.dothome.co.kr\/?p=448\" class=\"more-link\">Continue reading <span class=\"meta-nav\">\u2192<\/span><\/a><\/p>\n<\/footer>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,33,11],"tags":[],"class_list":["post-448","post","type-post","status-publish","format-standard","hentry","category-back-end","category-developement","category-spring"],"_links":{"self":[{"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/448"}],"collection":[{"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=448"}],"version-history":[{"count":1,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions"}],"predecessor-version":[{"id":449,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/448\/revisions\/449"}],"wp:attachment":[{"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=448"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=448"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/happily70.dothome.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=448"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}