{"id":98504,"date":"2020-03-27T20:37:26","date_gmt":"2020-03-27T12:37:26","guid":{"rendered":"http:\/\/4563.org\/?p=98504"},"modified":"2020-03-27T20:37:26","modified_gmt":"2020-03-27T12:37:26","slug":"springboot-requestbody-%e6%8e%a5%e6%94%b6%e6%b3%9b%e5%9e%8b%e5%ae%9e%e4%bd%93%e7%b1%bb%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=98504","title":{"rendered":"springboot @RequestBody \u63a5\u6536\u6cdb\u578b\u5b9e\u4f53\u7c7b\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  springboot @RequestBody \u63a5\u6536\u6cdb\u578b\u5b9e\u4f53\u7c7b\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : b19g3r <\/span>  <span><i><\/i> 45<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>@RestController @RequestMapping(\"\/demo\") @Slf4j public class DemoController&lt;T extends Shape&gt; {      @PostMapping(\"\/test\")     public JsonResponse createContract(@Validated @RequestBody DemoDTO&lt;T&gt; dto, BindingResult result) {         ... ...     } } <\/code><\/pre>\n<pre><code>{     \"seq\": \"1234\",     \"shape\": {         \"color\":\"red\",         \"name\":\"demo\",         \"linesNum\":\"6\"     } } <\/code><\/pre>\n<pre><code>public class DemoDTO&lt;T extends Shape&gt; {     String seq;     T shape; }  <\/code><\/pre>\n<p>\u6cdb\u578b\u5bf9\u5e94\u7684\u662f DTO \u7684\u4e00\u4e2a\u5c5e\u6027\u5bf9\u8c61;<br \/> \u8bf7\u95ee\u4e0b\u5927\u5bb6: \u5982\u4f55\u80fd\u6839\u636e\u4e0d\u540c\u7684\u62a5\u6587\u8f6c\u6362\u6210\u4e0d\u540c\u7684\u5bf9\u8c61\u5462?<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"712147\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u6837\u5c31\u53ef\u4ee5\u4e86\uff0c\u65b9\u6cd5\u7b7e\u540d\u7684\u53c2\u6570\u7c7b\u578b\u4fe1\u606f\u662f\u5e26\u6cdb\u578b\u4fe1\u606f\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"712148\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : b19g3r <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @guyeu \u6211\u548c\u540c\u4e8b\u8bd5\u4e86\u4e00\u4f1a\u53d1\u73b0\u6211\u8fd9\u79cd\u5b9e\u73b0\u65b9\u5f0f\u4e0d\u884c.<\/p>\n<p>\u6211\u627e\u5230\u4e86\u6700\u4f73\u7b54\u6848, \u6b64\u5e16\u7ec8\u7ed3 : )<\/p>\n<p>https:\/\/juejin.im\/post\/5d3d4c5f6fb9a07edd2a5a76                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"712149\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : b19g3r <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @b19g3r \u6211\u76ee\u524d\u8ba4\u4e3a\u7684\u6700\u4f73\u7b54\u6848 hhh                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"712150\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : b19g3r <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             see also:<br \/>https:\/\/stackoverflow.com\/a\/31666888\/751579                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>springboot @Reque&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/98504"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98504"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/98504\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98504"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}