{"id":348,"date":"2024-07-20T09:28:59","date_gmt":"2024-07-20T01:28:59","guid":{"rendered":"https:\/\/forelink.top\/?p=348"},"modified":"2024-07-20T09:29:00","modified_gmt":"2024-07-20T01:29:00","slug":"1-springmvc%e6%a6%82%e8%bf%b0","status":"publish","type":"post","link":"https:\/\/forelink.top\/index.php\/2024\/07\/20\/1-springmvc%e6%a6%82%e8%bf%b0\/","title":{"rendered":"1.SpringMVC\u6982\u8ff0"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"springmvc\">SpringMVC<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5185\u5bb9\uff1a\">\u5185\u5bb9\uff1a<\/h2>\n\n\n\n<p>\u8bf7\u6c42\u4e0e\u54cd\u5e94<\/p>\n\n\n\n<p>REST\u98ce\u683c<\/p>\n\n\n\n<p>SSM\u6574\u5408<\/p>\n\n\n\n<p>\u62e6\u622a\u5668<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5b66\u4e60\u76ee\u6807\uff1a\">\u5b66\u4e60\u76ee\u6807\uff1a<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u638c\u63e1\u57fa\u4e8eSpringMVC\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570\u4e0e\u54cd\u5e94json\u6570\u636e\u64cd\u4f5c<\/li>\n\n\n\n<li>\u719f\u7ec3\u5e94\u7528\u57fa\u4e8eREST\u98ce\u683c\u7684\u8bf7\u6c42\u8def\u5f84\u8bbe\u7f6e\u4e0e\u53c2\u6570\u4f20\u9012<\/li>\n\n\n\n<li>\u80fd\u591f\u6839\u636e\u5b9e\u9645\u4e1a\u52a1\u5efa\u7acb\u524d\u540e\u7aef\u5f00\u53d1\u901a\u4fe1\u534f\u8bae\u5e76\u8fdb\u884c\u5b9e\u73b0<\/li>\n\n\n\n<li>\u57fa\u4e8eSSM\u6574\u5408\u6280\u672f\u5f00\u53d1\u4efb\u610f\u4e1a\u52a1\u6a21\u5757\u529f\u80fd<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u6982\u8ff0\uff1a\">\u6982\u8ff0\uff1a<\/h2>\n\n\n\n<p>SpringMVC\u6280\u672f\u4e0eServlet\u6280\u672f\u529f\u80fd\u7b49\u540c\uff0c\u5747\u5c5e\u4e8eweb\u5c42\u5f00\u53d1\u6280\u672f<\/p>\n\n\n\n<p>SpringMVC\u662f\u4e00\u79cd\u57fa\u4e8eJava\u5b9e\u73b0MVC\u6a21\u578b\u7684\u8f7b\u91cf\u7ea7Web\u6846\u67b6\n\u4f18\u70b9\uff1a\u4f7f\u7528\u7b80\u5355\uff0c\u5f00\u53d1\u4fbf\u6377\n            \u7075\u6d3b\u6027\u5f3a<\/p>\n\n\n\n<p>Servlet\u5b9e\u73b0\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@WebServlet(\"\/user\/save\") \/\/\u751f\u6548\u7684\u8def\u5f84\npublic class UserServlet extends HttpServlet{\n    @Override\n    protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws Servlet Exception, IOException{\n        \/\/1.\u63a5\u53d7\u8bf7\u6c42\u53c2\u6570\n        String name = req.getParameter(\"name\");\n        sout(\"servlet save name ==&gt; \" + name);\n        \/\/2.\u4ea7\u751f\u54cd\u5e94\n        resp.setContentType(\"text\/json;charset=utf-8\");\n        PrintWriter pw = resp.getWriter();\n        pw.write(\"{'module':'servlet save'}\");\/\/\u628a\u5185\u5bb9\u663e\u793a\u5230\u6d4f\u89c8\u5668\u4e0a\n    }\n    \n    @Override\n    protected void doPost(HttpServletRequest req,HttpServletResponse resp) throws Servlet Exception, IOException{\n        this.doGet(req,resp);\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>SpringMVC\u5b9e\u73b0\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Controller\npublic class UserController{\n    @RequestMapping(\"\/save\")\n    @ResponseBody\n    public String save(String name){\n        sout(\"springmvc save name ==&gt; \" + name);\n        return \"{'module':'springmvc save'}\";\n    }\n    \n    @RequestMapping(\"\/delete\")\n    @ResponseBody\n    public String delete(String name){\n        sout(\"springmvc delete name ==&gt; \" + name);\n        return \"{'module':'springmvc delete'}\";\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>\u200b    \u7528SpringMVC\u4e66\u5199\uff0c\u5f00\u53d1\u66f4\u7b80\u6d01\uff0c\u63a5\u53d7\u53c2\u6570\u66f4\u65b9\u4fbf\uff0c\u90fd\u5c01\u88c5\u5728RequestBody\u4e2d\u7edf\u4e00\u63a5\u53d7\u3002<\/p>\n\n\n\n<p>\u6570\u636e\u5c42\uff1aJDBC ==&gt; MyBatis<\/p>\n\n\n\n<p>\u8868\u73b0\u5c42\uff1aServlet ==&gt; SpringMVC \uff08web\u6846\u67b6\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SpringMVC \u5185\u5bb9\uff1a \u8bf7\u6c42\u4e0e\u54cd\u5e94 REST\u98ce\u683c SSM\u6574\u5408 \u62e6\u622a\u5668 \u5b66\u4e60\u76ee\u6807\uff1a \u6982\u8ff0\uff1a SpringMV [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[28,17],"tags":[],"class_list":["post-348","post","type-post","status-publish","format-standard","hentry","category-spring","category-17"],"_links":{"self":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/comments?post=348"}],"version-history":[{"count":1,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/348\/revisions"}],"predecessor-version":[{"id":349,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/348\/revisions\/349"}],"wp:attachment":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/media?parent=348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/categories?post=348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/tags?post=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}