{"id":1009,"date":"2021-07-18T10:34:00","date_gmt":"2021-07-18T02:34:00","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=1009"},"modified":"2022-06-14T10:42:18","modified_gmt":"2022-06-14T02:42:18","slug":"%e5%95%a5%e6%98%afrestful%ef%bc%9f%ef%bc%9f%e4%bb%96%e6%98%af%e7%94%a8%e6%9d%a5%e5%b9%b2%e5%98%9b%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=1009","title":{"rendered":"\u5565\u662fRestful\uff1f\uff1f\u4ed6\u662f\u7528\u6765\u5e72\u561b\u7684\uff1f"},"content":{"rendered":"\n<p>\u6700\u8fd1\u5237\u4e86\u4e00\u4e9bjd\uff0c\u53d1\u73b0\u603b\u63d0\u5230\u8fd9\u4e2a\u8bcd\uff0c\u540e\u6765\u67e5\u4e86\u4e00\u4e0b \u53d1\u73b0\u8fd9\u5757\u5bf9\u4e8e\u4e1a\u52a1\u5f00\u53d1\u6765\u8bf4\u8fd8\u662f\u86ee\u91cd\u8981\u7684\u3002<\/p>\n\n\n\n<p><strong>\u5b9a\u4e49\uff1a<\/strong>RESTFUL\u662f\u4e00\u79cd\u7f51\u7edc\u5e94\u7528\u7a0b\u5e8f\u7684\u8bbe\u8ba1\u98ce\u683c\u548c\u5f00\u53d1\u65b9\u5f0f\uff0c\u57fa\u4e8e<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/HTTP\/243074\">HTTP<\/a>\uff0c\u53ef\u4ee5\u4f7f\u7528<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/XML\/86251\">XML<\/a>\u683c\u5f0f\u5b9a\u4e49\u6216<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/JSON\/2462549\">JSON<\/a>\u683c\u5f0f\u5b9a\u4e49\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7ffb\u8bd1\u8fc7\u6765\u5c31\u662f\uff1a<strong>\u7528 URL \u5b9a\u4f4d\u8d44\u6e90\uff0c\u7528 HTTP \u52a8\u8bcd\uff08GET\uff0cPOST\uff0cDELETE\uff0cPUT\uff09\u63cf\u8ff0\u64cd\u4f5c\u3002<\/strong><\/p>\n\n\n\n<p>RESTful\u67b6\u6784\u662f\u5bf9MVC\u67b6\u6784\u6539\u8fdb\u540e\u6240\u5f62\u6210\u7684\u4e00\u79cd\u67b6\u6784\uff0c\u901a\u8fc7\u4f7f\u7528\u4e8b\u5148\u5b9a\u4e49\u597d\u7684\u63a5\u53e3\u4e0e\u4e0d\u540c\u7684\u670d\u52a1\u8054\u7cfb\u8d77\u6765\u3002<\/p>\n\n\n\n<p>\u5728RESTful\u67b6\u6784\u4e2d\uff0c\u6d4f\u89c8\u5668\u4f7f\u7528POST\uff0cDELETE\uff0cPUT\u548cGET\u56db\u79cd\u8bf7\u6c42\u65b9\u5f0f\u5206\u522b\u5bf9\u6307\u5b9a\u7684URL\u8d44\u6e90\u8fdb\u884c\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0cRESTful\u662f\u901a\u8fc7URI\u5b9e\u73b0\u5bf9\u8d44\u6e90\u7684\u7ba1\u7406\u53ca\u8bbf\u95ee\uff0c\u5177\u6709\u6269\u5c55\u6027\u5f3a\u3001\u7ed3\u6784\u6e05\u6670\u7684\u7279\u70b9\u3002<\/p>\n\n\n\n<p>(vue\/React)MVVM : RESTful\u67b6\u6784\u5c06<a rel=\"noreferrer noopener\" target=\"_blank\" href=\"https:\/\/baike.baidu.com\/item\/%E6%9C%8D%E5%8A%A1%E5%99%A8\/100571\">\u670d\u52a1\u5668<\/a>\u5206\u6210\u524d\u7aef\u670d\u52a1\u5668\u548c\u540e\u7aef\u670d\u52a1\u5668\u4e24\u90e8\u5206\uff0c\u524d\u7aef\u670d\u52a1\u5668\u4e3a\u7528\u6237\u63d0\u4f9b\u65e0\u6a21\u578b\u7684\u89c6\u56fe\uff1b\u540e\u7aef\u670d\u52a1\u5668\u4e3a\u524d\u7aef\u670d\u52a1\u5668\u63d0\u4f9b\u63a5\u53e3\u3002<\/p>\n\n\n\n<p>\u6d4f\u89c8\u5668\u5411\u524d\u7aef\u670d\u52a1\u5668\u8bf7\u6c42\u89c6\u56fe\uff0c\u901a\u8fc7\u89c6\u56fe\u4e2d\u5305\u542b\u7684AJAX\u51fd\u6570\u53d1\u8d77\u63a5\u53e3\u8bf7\u6c42\u83b7\u53d6\u6a21\u578b\u3002\u9879\u76ee\u5f00\u53d1\u5f15\u5165RESTful\u67b6\u6784\uff0c\u5229\u4e8e\u56e2\u961f\u5e76\u884c\u5f00\u53d1\u3002<\/p>\n\n\n\n<p>\u5728RESTful\u67b6\u6784\u4e2d\uff0c\u5c06\u591a\u6570HTTP\u8bf7\u6c42\u8f6c\u79fb\u5230\u524d\u7aef\u670d\u52a1\u5668\u4e0a\uff0c\u964d\u4f4e\u670d\u52a1\u5668\u7684\u8d1f\u8377\uff0c\u4f7f\u89c6\u56fe\u83b7\u53d6\u540e\u7aef\u6a21\u578b\u5931\u8d25\u4e5f\u80fd\u5448\u73b0\u3002\u4f46RESTful\u67b6\u6784\u5374\u4e0d\u9002\u7528\u4e8e\u6240\u6709\u7684\u9879\u76ee\uff0c\u5f53\u9879\u76ee\u6bd4\u8f83\u5c0f\u65f6\u65e0\u9700\u4f7f\u7528RESTful\u67b6\u6784\uff0c\u9879\u76ee\u53d8\u5f97\u66f4\u52a0\u590d\u6742\u3002<\/p>\n\n\n\n<p><strong>\u77e5\u4e4e\u4e0a<\/strong>\u53e6\u4e00\u5927\u795e\u5bf9 RESTful \u7684\u89e3\u91ca\uff0c\u76f8\u6bd4\u4e8e Ivony \u591a\u4e86\u4e00\u53e5\u8bdd\uff0c\u4ed6\u7528\u4e86\u4e09\u53e5\u8bdd\u6765\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<ul><li>\u770b Url \u5c31\u77e5\u9053\u8981\u4ec0\u4e48<\/li><li>\u770b http method \u5c31\u77e5\u9053\u5e72\u4ec0\u4e48<\/li><li>\u770b http status code \u5c31\u77e5\u9053\u7ed3\u679c\u5982\u4f55<\/li><li><\/li><\/ul>\n\n\n\n<p>http \u72b6\u6001\u7801\u6709 100 \u591a\u79cd\uff0c\u6211\u4eec\u5e76\u4e0d\u9700\u8981\u5168\u90e8\u7528\u5230\uff0c\u53ea\u9700\u8981\u4e86\u89e3\u5176\u4e2d\u5e38\u7528\u7684\u5c31\u53ef\u4ee5\u4e86<\/p>\n\n\n\n<ul><li>200 \u2013 OK \u2013 \u4e00\u5207\u6b63\u5e38<\/li><li>201 \u2013 OK \u2013 \u65b0\u8d44\u6e90\u5df2\u7ecf\u88ab\u521b\u5efa<\/li><li>204 \u2013 OK \u2013 \u8d44\u6e90\u5220\u9664\u6210\u529f<\/li><li>304 \u2013 \u6ca1\u6709\u53d8\u5316\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u4f7f\u7528\u7f13\u5b58\u6570\u636e<\/li><li>400 \u2013 Bad Request \u2013 \u8c03\u7528\u4e0d\u5408\u6cd5\uff0c\u786e\u5207\u7684\u9519\u8bef\u5e94\u8be5\u5728 error payload \u4e2d\u63cf\u8ff0<\/li><li>401 \u2013 \u672a\u8ba4\u8bc1\uff0c\u8c03\u7528\u9700\u8981\u7528\u6237\u901a\u8fc7\u8ba4\u8bc1<\/li><li>403 \u2013 \u4e0d\u5141\u8bb8\u7684\uff0c\u670d\u52a1\u7aef\u6b63\u5e38\u89e3\u6790\u548c\u8bf7\u6c42\uff0c\u4f46\u662f\u8c03\u7528\u88ab\u56de\u7edd\u6216\u8005\u4e0d\u88ab\u5141\u8bb8<\/li><li>404 \u2013 \u672a\u627e\u5230\uff0c\u6307\u5b9a\u7684\u8d44\u6e90\u4e0d\u5b58\u5728<\/li><li>422 \u2013 \u4e0d\u53ef\u6307\u5b9a\u7684\u8bf7\u6c42\u4f53 \u2013 \u53ea\u6709\u670d\u52a1\u5668\u4e0d\u80fd\u5904\u7406\u5b9e\u4f53\u65f6\u4f7f\u7528\uff0c\u6bd4\u5982\u56fe\u50cf\u4e0d\u80fd\u88ab\u683c\u5f0f\u5316\uff0c\u6216\u8005\u91cd\u8981\u5b57\u6bb5\u4e22\u5931<\/li><li>500 \u2013 Internal Server Error \u2013 \u6807\u51c6\u670d\u52a1\u7aef\u9519\u8bef\uff0c\u5f00\u53d1\u4eba\u5458\u5e94\u8be5\u5c3d\u91cf\u907f\u5f00\u8fd9\u79cd\u9519\u8bef<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5237\u4e86\u4e00\u4e9bjd\uff0c\u53d1\u73b0\u603b\u63d0\u5230\u8fd9\u4e2a\u8bcd\uff0c\u540e\u6765\u67e5\u4e86\u4e00\u4e0b \u53d1\u73b0\u8fd9\u5757\u5bf9\u4e8e\u4e1a\u52a1\u5f00\u53d1\u6765\u8bf4\u8fd8\u662f\u86ee\u91cd\u8981\u7684\u3002 \u5b9a\u4e49\uff1aRESTFUL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[19],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1009"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1009"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1009\/revisions"}],"predecessor-version":[{"id":1010,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/1009\/revisions\/1010"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1009"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}