{"id":14871,"date":"2024-05-15T09:55:16","date_gmt":"2024-05-15T01:55:16","guid":{"rendered":"https:\/\/92it.top\/?p=14871"},"modified":"2024-05-15T09:55:16","modified_gmt":"2024-05-15T01:55:16","slug":"spring-boot-%e5%92%8c-servlet-%e7%9a%84%e5%85%b3%e7%b3%bb","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=14871","title":{"rendered":"Spring boot \u548c Servlet \u7684\u5173\u7cfb"},"content":{"rendered":"\n<p><strong>\u80cc\u666f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5f00\u53d1\u4e86\u5f88\u4e45\u7684web\u670d\u52a1\uff0c\u4f7f\u7528\u4e86\u5f88\u591aweb\u6846\u67b6\uff0c\u90fd\u5fd8\u8bb0web\u6280\u672f\u6700\u539f\u59cb\u7684\u6a21\u6837\u4e86\uff0c\u4eca\u5929\u6765\u56de\u987e\u4e0b\u3002<\/p>\n\n\n\n<p><strong>\u9996\u5148\u56de\u5fc6\u4e0bweb\u670d\u52a1\u5668\u548ctomcat<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>web\u6280\u672f\u5206\u4e3a<code>\u52a8\u6001<\/code>(servlet\u6280\u672f)\u548c<code>\u9759\u6001html<\/code>\uff1b<\/p>\n\n\n\n<p>\u4e0d\u7ba1\u52a8\u6001\u8fd8\u662f\u9759\u6001\uff0c\u8bbf\u95eeweb\u90fd\u662f\u901a\u8fc7http\u534f\u8bae\uff0c\u4f60\u7406\u89e3\u4e3a\u90fd\u662furl\u8bbf\u95ee(\u4e0d\u7ba1\u52a8\u6001\u8fd8\u662f\u9759\u6001\u90fd\u662furl\u8bbf\u95ee)\uff0c\u56e0\u6b64\u4e00\u822c<code>web\u670d\u52a1\u5668==HTTP\u670d\u52a1\u5668<\/code><\/p>\n\n\n\n<p>web\u5bb9\u5668\uff08web\u670d\u52a1\u5668\uff09\u4e3b\u8981\u6709\uff1aApache\u3001IIS\u3001Tomcat\u3001Jetty\u3001JBoss\u3001webLogic\u7b49\uff0c\u800cTomcat\u3001Jetty\u3001JBoss\u3001webLogic\u540c\u65f6\u4e5f\u662fservlet\u5bb9\u5668\uff0c\u6216\u8005\u8bf4\u4ed6\u4eec\u8fd8\u5305\u542b\u4e86servlet\u5bb9\u5668\uff0c\u539f\u56e0\u662f\u652f\u6301\u52a8\u6001\uff0c\u5373servlet\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u4e0e\u52a8\u6001\u4e0d\u540c\u7684\u662f\uff0cApache\u4ec5\u652f\u6301\u9759\u6001Hmtl<\/p>\n\n\n\n<p>Apache\u548cTomcat\u533a\u522b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"141\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-1024x141.png\" alt=\"\" class=\"wp-image-14872\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-1024x141.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-300x41.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-768x106.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-1536x212.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-830x115.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-230x32.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-350x48.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273-480x66.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-273.png 1638w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">Apache:\u5728Web\u670d\u52a1\u5668\u4e2d\uff0cApache\u662f\u7eaf\u7cb9\u7684Web\u670d\u52a1\u5668\uff0c\u7ecf\u5e38\u4e0eTomcat\u914d\u5bf9\u4f7f\u7528\u3002\u5b83\u5bf9HTML\u9875\u9762\u5177\u6709\u5f3a\u5927\u7684\u89e3\u91ca\u80fd\u529b\uff0c\u4f46\u662f\u4e0d\u80fd\u89e3\u91ca\u5d4c\u5165\u9875\u9762\u5185\u7684\u670d\u52a1\u5668\u7aef\u811a\u672c\u4ee3\u7801\uff08JSP\/Servlet\uff09\u3002<br><br>Tomcat:\u65e9\u671f\u7684Tomcat\u662f\u4e00\u4e2a\u5d4c\u5165Apache\u5185\u7684JSP\/Servlet\u89e3\u91ca\u5f15\u64ceApache+Tomcat\u5c31\u76f8\u5f53\u4e8eIIS+ASP\u3002\u540e\u6765\u7684Tomcat\u5df2\u4e0d\u518d\u5d4c\u5165Apache\u5185\uff0cTomcat\u8fdb\u7a0b\u72ec\u7acb\u4e8eApache\u8fdb\u7a0b\u8fd0\u884c\u3002 \u800c\u4e14\uff0cTomcat\u5df2\u7ecf\u662f\u4e00\u4e2a\u72ec\u7acb\u7684Servlet\u548cJSP\u5bb9\u5668\uff0c\u4e1a\u52a1\u903b\u8f91\u5c42\u4ee3\u7801\u548c\u754c\u9762\u4ea4\u4e92\u5c42\u4ee3\u7801\u53ef\u4ee5\u5206\u79bb\u4e86\u3002\u56e0\u6b64\uff0c\u6709\u4eba\u628aTomcat\u53eb\u505a\u8f7b\u91cf\u7ea7\u5e94\u7528\u670d\u52a1\u5668\u3002<br><br>IIS:\u5fae\u8f6f\u65e9\u671f\u7684IIS\uff0c\u5c31\u662f\u4e00\u4e2a\u7eaf\u7cb9\u7684Web\u670d\u52a1\u5668\u3002\u540e\u6765\uff0c\u5b83\u5d4c\u5165\u4e86ASP\u5f15\u64ce\uff0c\u53ef\u4ee5\u89e3\u91caVBScript\u548cJScript\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u4e86\uff0c\u8fd9\u65f6\uff0c\u5b83\u5c31\u53ef\u4ee5\u517c\u4f5c\u5e94\u7528\u670d\u52a1\u5668\u3002\u5f53\u7136\uff0c\u5b83\u4e0eJ2EE\u5e94\u7528\u670d\u52a1\u5668\u6839\u672c\u65e0\u6cd5\u76f8\u6bd4\uff0c\u4f46\u662f\uff0c\u4ece\u529f\u80fd\u4e0a\u8bf4\uff0c\u4ece\u539f\u7406\u4e0a\u8bf4\uff0c\u5b83\u52c9\u5f3a\u53ef\u4ee5\u79f0\u4e4b\u4e3a\u5e94\u7528\u670d\u52a1\u5668\u3002\u786e\u5207\u5730\u8bf4\uff0c\u5b83\u662f\u517c\u6709\u4e00\u70b9\u5e94\u7528\u670d\u52a1\u5668\u529f\u80fd\u7684Web\u670d\u52a1\u5668\u3002<\/pre>\n\n\n\n<p>Apache \u548c Tomcat \u90fd\u662fweb\u7f51\u7edc\u670d\u52a1\u5668\uff0c\u4e24\u8005\u65e2\u6709\u8054\u7cfb\u53c8\u6709\u533a\u522b\uff1a<\/p>\n\n\n\n<ul>\n<li>Apache\u662fweb\u670d\u52a1\u5668\uff08\u4ec5\u652f\u6301\u9759\u6001\u89e3\u6790\uff0c\u5982HTML\uff09<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u4e5f\u5c31\u662f\u8bf4\u4f60\u5728\u670d\u52a1\u5668\u7684\u76ee\u5f55\u4e0b\u9762\u4e22\u4e2aindex.html\uff0c\u901a\u8fc7http:xxx\/\/8080\/index.html\u53ef\u4ee5\u8bbf\u95ee\n\u5018\u82e5\u4e22\u4e2aindex.jsp\uff0c\u65e0\u6cd5\u89e3\u6790\uff0c\u65e0\u6cd5\u901a\u8fc7http:xxx\/\/8080\/index.jsp\u8bbf\u95ee<\/pre>\n\n\n\n<ul>\n<li>tomcat\u662fjava\u5e94\u7528\u670d\u52a1\u5668\uff08\u652f\u6301\u52a8\u6001\u89e3\u6790\uff0c\u5982JSP\uff09<\/li>\n<\/ul>\n\n\n\n<p>index.html\u548cindex.jsp\u5747\u652f\u6301\uff0c\u4f46\u5bf9\u9759\u6001\u6587\u4ef6\u5904\u7406\u7684\u6027\u80fd\u5dee\uff0c\u8fd9\u4e00\u70b9\u4e0d\u5982Apache \u6548\u7387\u9ad8<\/p>\n\n\n\n<p>Tomcat\u53ea\u662f\u4e00\u4e2aservlet(jsp\u4e5f\u7ffb\u8bd1\u6210servlet)\u5bb9\u5668\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u662fapache\u7684\u6269\u5c55\uff0c\u4f46\u662f\u53ef\u4ee5\u72ec\u7acb\u4e8eapache\u8fd0\u884c\u3002<\/p>\n\n\n\n<p>Apache\u662f\u5f88\u6700\u5f00\u59cb\u7684\u9875\u9762\u89e3\u6790\u670d\u52a1\uff0ctomcat\u662f\u540e\u7814\u53d1\u51fa\u6765\u7684\uff0c\u4ece\u672c\u8d28\u4e0a\u6765\u8bf4tomcat\u7684\u529f\u80fd\u5b8c\u5168\u53ef\u4ee5\u66ff\u4ee3Apache\uff0c\u4f46Apache\u6bd5\u7adf\u662ftomcat\u7684\u524d\u8f88\u7ea7\u4eba\u7269\uff0c\u5e76\u4e14\u5e02\u573a\u4e0a\u4e5f\u6709\u4e0d\u5c11\u4eba\u8fd8\u5728\u7528Apache\uff0c\u6240\u4ee5Apache\u8fd8\u4f1a\u7ee7\u7eed\u5b58\u5728\uff0c\u4e0d\u4f1a\u88ab\u53d6\u4ee3\uff0capache\u4e0d\u80fd\u89e3\u6790java\u7684\u4e1c\u897f\uff0c\u4f46\u89e3\u6790html\u901f\u5ea6\u5feb\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u7531\u4e8e\u5404\u6709\u4f18\u7f3a\u70b9\uff0c\u4e00\u822c\u4f1a\u6574\u5408\u4f7f\u7528\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5982\u679c\u8bf7\u6c42\u662f\u9759\u6001\u7f51\u9875\u5219\u7531Apache\u5904\u7406\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\uff1b<\/li>\n\n\n\n<li>\u5982\u679c\u662f\u52a8\u6001\u8bf7\u6c42\uff0cApache\u4f1a\u5c06\u89e3\u6790\u5de5\u4f5c\u8f6c\u53d1\u7ed9Tomcat\u5904\u7406\uff0cTomcat\u5904\u7406\u540e\u5c06\u7ed3\u679c\u901a\u8fc7Apache\u8fd4\u56de\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u6837\u53ef\u4ee5\u8fbe\u5230\u5206\u5de5\u5408\u4f5c\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u6027\u80fd\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"657\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-1024x657.png\" alt=\"\" class=\"wp-image-14873\" style=\"width:494px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-1024x657.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-300x192.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-768x493.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-830x533.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-230x148.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-350x225.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274-480x308.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-274.png 1250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u6765\u81ea\u5176\u4ed6\u7f51\u7ad9\u7684\u56de\u7b54<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"870\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-1024x870.png\" alt=\"\" class=\"wp-image-14876\" style=\"width:530px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-1024x870.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-300x255.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-768x653.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-1536x1305.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-830x705.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-230x195.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-350x297.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276-480x408.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-276.png 1930w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u67d0\u79cd\u7a0b\u5ea6\u4e0a\uff0cServlet \u5c31\u662f Spring Boot \u7684\u5e95\u5c42\u57fa\u7840\u4ee3\u7801<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Servlet \u662f Sun \u516c\u53f8\u6240\u8bbe\u8ba1\u5f00\u53d1\u7684\u53ef\u4ee5\u7528\u4e8e\u63a5\u6536\u548c\u5904\u7406 HTTP \u8bf7\u6c42\u7684 Java \u7c7b\u3002<\/p>\n\n\n\n<p>Servlet\u662fsun\u516c\u53f8\u63d0\u4f9b\u7684\u4e00\u95e8\u7528\u4e8e\u5f00\u53d1\u52a8\u6001web\u8d44\u6e90\u7684\u6280\u672f\u3002\u6211\u4eec\u666e\u901a\u7684Java\u7c7b\u5b9e\u73b0\u4e86Servlet\u63a5\u53e3\u540e\uff0c\u53ef\u5c06\u6211\u4eec\u7684\u670d\u52a1\u90e8\u7f72\u5728Web\u5bb9\u5668\u4e2d\uff0c\u8fd9\u6837\u6211\u4eec\u7684\u670d\u52a1\u5c31\u53ef\u4ee5\u63d0\u4f9bWeb\u670d\u52a1\u4e86\u3002<\/p>\n\n\n\n<p>Servlet\u662fJavaWeb\u6700\u4e3a\u6838\u5fc3\u7684\u5185\u5bb9\uff0c\u5b83\u662fJava\u63d0\u4f9b\u7684\u4e00\u95e8\u52a8\u6001web\u8d44\u6e90\u5f00\u53d1\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u4ee5\u524d\u7684java web\u9879\u76ee\uff0c\u9700\u8981\u5728web.xml\u4e2d\u5b9a\u4e49servlet\uff0c\u5bf9\u5e94\u4e0d\u540c\u7684\u8bf7\u6c42\uff0c\u800c\u5728spring\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u7528controller\u5b9a\u4e49\u4e86\u5404\u79cd\u5404\u6837\u7684servlet\uff08\u5f53\u7136\u4e0d\u5305\u62ecDispatcherServlet\uff09\uff0c\u90a3\u4e48controller\u662fservlet\u5417\uff1f<br>servlet\u7684\u672c\u8d28\u5176\u5b9e\u4e5f\u662f\u4e00\u4e2ajava bean\uff0ccontroller\u662f\u5bf9servlet\u7684\u5c01\u88c5\uff0c\u5e95\u5c42\u4f9d\u65e7\u662fservlet\u3002<br>web\u5f00\u53d1\u4f7f\u7528Controller\u57fa\u672c\u80fd\u89e3\u51b3\u5927\u90e8\u5206\u7684\u9700\u6c42\uff0c\u4f46\u662f\u6709\u65f6\u5019\u6211\u4eec\u4e5f\u9700\u8981\u4f7f\u7528Servlet\uff0c\u56e0\u4e3a\u76f8\u5bf9\u4e8e\u62e6\u622a\u548c\u76d1\u542c\u6765\u8bf4\uff0c\u6709\u65f6\u5019\u539f\u751f\u7684\u8fd8\u662f\u6bd4\u8f83\u597d\u7528\u7684\uff0c\u73b0\u5728\u5c31\u6765\u7b80\u5355\u7684\u5728SpringBoot\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u7279\u6b8a\u7c7b\u5427\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u8bf4\uff0cServlet\u5c31\u662fSpringBoot\u5728web\u670d\u52a1\u7684\u5e95\u5c42\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>Spring MVC \u8fd9\u6837\u7684\u6846\u67b6\u5c31\u662f\u5bf9 Servlet \u7684\u4e8c\u6b21\u5c01\u88c5\uff0c\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u81ea\u52a8\u7684\u4ece HTTP \u8bf7\u6c42\u4e2d\u83b7\u5f97\u8bf7\u6c42\u53c2\u6570\u7b49\u5de5\u4f5c\uff0c\u8ba9\u6211\u4eec\u53ef\u4ee5\u5c06\u7cbe\u529b\u96c6\u4e2d\u5728\u4e1a\u52a1\u4ee3\u7801\u4e0a\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u8fc7 Spring MVC \u7684\uff0c\u4f60\u5c31\u77e5\u9053 Spring MVC \u6846\u67b6\u8981\u60f3\u542f\u52a8\uff0c\u5fc5\u987b\u914d\u7f6e Spring MVC \u6700\u6838\u5fc3\u7684\u4e00\u4e2a\u7c7b\uff0cDispatcherServlet\uff0c\u8fd9\u4e2a\u7c7b\u5c31\u662f Servlet\uff0c\u6ca1\u6709\u8fd9\u4e2a\u6838\u5fc3\u7c7b\uff0c\u4f60\u8fde\u6574\u4e2a Spring MVC \u6846\u67b6\u90fd\u542f\u52a8\u4e0d\u4e86\u3002<\/p>\n\n\n\n<p>Spring Boot \u5176\u5b9e\u5c31\u662f\u5bf9 Spring MVC \u7684\u4e8c\u6b21\u5c01\u88c5\uff0c\u80fd\u591f\u4f7f\u6211\u4eec\u4e0d\u5728\u56f0\u4e8e Spring MVC \u7e41\u7410\u7684 XML \u914d\u7f6e\u4e2d\uff0c\u80fd\u591f\u5b9e\u73b0\u5f00\u7bb1\u5373\u7528\u7684\u4fbf\u5229\u7a0b\u5ea6\u3002\u56e0\u6b64 Spring Boot \u7684\u5e95\u5c42\u5c31\u662f Spring MVC\uff0c\u800c Spring MVC \u7684\u5e95\u5c42\u5c31\u662f Servlet\u3002<\/p>\n\n\n\n<p>springboot\u672c\u8eab\u9ed8\u8ba4\u5c01\u88c5\u4e86tomcat\uff0c\u6240\u4ee5\u672c\u8d28\u4e0a\u8fd8\u662f\u7528\u5230\u4e86servlet\u6280\u672f\u3002\u53ea\u4e0d\u8fc7\u662f\u901a\u8fc7\u6846\u67b6\u7ee7\u7eed\u4f7f\u7528\u3002\u6bd4\u5982springmvc\u6846\u67b6\uff0c\u4e5f\u53ef\u4ee5\u7b80\u5355\u7684\u7406\u89e3\u4e3aspringmvc\u6846\u67b6\u662f\u5bf9servlet\u7684\u518d\u5c01\u88c5\u548c\u6269\u5c55\u3002\u867d\u7136\u5df2\u7ecf\u7528\u5230servlet\u6280\u672f\u4e86\uff0c\u4f46\u662f\u4f60\u5199\u7684\u4ee3\u7801\u90fd\u662fspringmvc\u7684\u4ee3\u7801\u6807\u51c6\u3002<\/p>\n\n\n\n<p>servlet\u662fspring\u7684\u57fa\u7840\uff0cspringboot\u662f\u4e3a\u4e86\u7b80\u5316spring\u7684\u914d\u7f6e\uff0c\u5e76\u5c01\u88c5\u6210\u4e86\u5fae\u670d\u52a1\u3002<\/p>\n\n\n\n<p><strong>Tomcat\u4e0eservlet\u4e4b\u95f4\u7684\u5173\u7cfb<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"566\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-1024x566.png\" alt=\"\" class=\"wp-image-14877\" style=\"width:546px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-1024x566.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-300x166.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-768x425.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-830x459.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-230x127.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-350x194.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277-480x266.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-277.png 1222w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"522\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-1024x522.png\" alt=\"\" class=\"wp-image-14878\" style=\"width:548px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-1024x522.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-300x153.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-768x391.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-1536x783.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-830x423.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-230x117.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-350x178.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278-480x245.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-278.png 1950w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u5982\u4f55\u4f7f\u7528Servlet\u642d\u5efaweb\u670d\u52a1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>1\u3001\u4f9d\u8d56\u5f15\u5165<\/p>\n\n\n\n<p>\u9700\u8981\u5728pom.xml\u4e2d\u6dfb\u52a0servlet\u4f9d\u8d56\uff0c\u7136\u540e\u624d\u53ef\u4ee5\u5728\u9879\u76ee\u4e2d\u4f7f\u7528HttpServlet<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!--\u52a0\u5165servlet\u4f9d\u8d56\uff08servlet\u7684jar\uff09-->\n    &lt;dependency>\n      &lt;groupId>javax.servlet&lt;\/groupId>\n      &lt;artifactId>javax.servlet-api&lt;\/artifactId>\n      &lt;version>4.0.1&lt;\/version>\n      &lt;scope>provided&lt;\/scope>\n    &lt;\/dependency>\n    &lt;!--jsp\u7684\u4f9d\u8d56\uff08jsp\u76f8\u5173\u7684jar\u52a0\u8fdb\u6765\uff09-->\n    &lt;dependency>\n      &lt;groupId>javax.servlet.jsp&lt;\/groupId>\n      &lt;artifactId>javax.servlet.jsp-api&lt;\/artifactId>\n      &lt;version>2.2.1&lt;\/version>\n      &lt;scope>provided&lt;\/scope>\n    &lt;\/dependency><\/pre>\n\n\n\n<p>2\u3001\u7f16\u5199\u63a5\u53e3\u670d\u52a1\u7c7b<\/p>\n\n\n\n<p>\u63a5\u53e3\u7c7b\u9700\u8981\u7ee7\u627fjavax.servlet.http.HttpServlet\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u5b9a\u4e49\u7684\u7c7b\u53ebHelloServlet<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public class HelloServlet extends HttpServlet{\n\t\/\/\u521d\u59cb\u5316servlet,\u8c03\u7528init\u65b9\u6cd5\n\t@Override\n\tpublic void init() throws ServletException {\n\t\tSystem.out.println(\"\u521d\u59cb\u5316\u65f6\u8c03\u7528\");\n\t}\n\t\/\/\u5f00\u542f\u670d\u52a1\n\t@Override\n\tprotected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {\n\t\tSystem.out.println(\"\u5f00\u542f\u670d\u52a1\u65f6\u8c03\u7528\");\n\t}\n\t@Override\n\tprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n\t\t\n\t}\n\t\/\/\u9500\u6bc1\u65f6\u8c03\u7528destory\n\t@Override\n\tpublic void destroy() {\n\t\tSystem.out.println(\"\u9500\u6bc1\u65f6\u8c03\u7528\");\n\t}\n}<\/pre>\n\n\n\n<p>3\u3001\u5728web.xml\u6587\u4ef6\u4e2d\u6ce8\u518cServlet\u7c7b<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!--\u4efb\u4f55\u4e00\u4e2aservlet\u90fd\u5bf9\u5e94\u4e00\u4e2aservlet-mapping-->\n  &lt;servlet>\n      &lt;servlet-name>hello&lt;\/servlet-name>\n      &lt;!--\u8fd9\u4e2a\u4f4d\u7f6e\u5fc5\u987b\u662f\u5e26\u6709\u5305\u540d\u7684\u5168\u9650\u5b9a\u7c7b\u540d-->\n      &lt;servlet-class>com.qiyi.HelloServlet&lt;\/servlet-class>\n  &lt;\/servlet>\n \n  &lt;!--servlet\u6620\u5c04\u4fe1\u606f-->\n  &lt;servlet-mapping>\n      &lt;!--\u8fd9\u91cc\u968f\u610f\u586b\u5199\uff0c\u4f46\u662f\u540d\u5b57\u5fc5\u987b\u4e0e\u4e0a\u65b9\u76f8\u540c-->\n      &lt;servlet-name>hello&lt;\/servlet-name>\n \n      &lt;!-\u8fd9\u91cc\u9700\u8981\u4e00\u4e2a\u8def\u5f84\uff0c\u5fc5\u987b\u4ee5\/\u5f00\u59cb\uff0c\u53ef\u4ee5\u968f\u4fbf\u5199-->\n      &lt;url-pattern>\/sdafs\/sada\/ds&lt;\/url-pattern>\n  &lt;\/servlet-mapping><\/pre>\n\n\n\n<p>4\u3001\u542f\u52a8Tomcat\u670d\u52a1\u5668<\/p>\n\n\n\n<p><strong>Servlet\u751f\u547d\u5468\u671f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>1\u3001\u56fe\u89e3\u8bf4\u660e<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"509\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-1024x509.png\" alt=\"\" class=\"wp-image-14879\" style=\"width:606px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-1024x509.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-300x149.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-768x382.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-830x413.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-230x114.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-350x174.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279-480x239.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-279.png 1448w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>2\u3001\u8bf4\u660e<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"222\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-1024x222.png\" alt=\"\" class=\"wp-image-14880\" style=\"width:620px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-1024x222.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-300x65.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-768x167.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-1536x334.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-830x180.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-230x50.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-350x76.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280-480x104.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-280.png 1658w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>3.\u751f\u547d\u5468\u671f\u65b9\u6cd5\u6267\u884c\u6d41\u7a0b<\/strong><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-1024x470.png\" alt=\"\" class=\"wp-image-14881\" style=\"width:626px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-1024x470.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-300x138.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-768x352.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-1536x705.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-830x381.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-230x106.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-350x161.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281-480x220.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-281.png 1656w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>Servlet\u89c4\u8303\u4e09\u5927\u7ec4\u4ef6<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>1\u3001\u4ecb\u7ecd<\/strong><\/p>\n\n\n\n<p>Servlet\u89c4\u8303\u4e09\u5927\u4ef6\u5206\u522b\u662f\uff1aservlet\u3001\u8fc7\u6ee4\u5668\u3001\u76d1\u542c\u5668<\/p>\n\n\n\n<p><strong>2\u3001\u62e6\u622a\u5668\u4e0e\u8fc7\u6ee4\u5668\u533a\u522b<\/strong><\/p>\n\n\n\n<p>\u62e6\u622a\u5668\u6838\u5fc3\u539f\u7406\uff1aAOP\u601d\u60f3<\/p>\n\n\n\n<p>\u8fc7\u6ee4\u5668\u662fServlet\u7684\u6280\u672f\u3002<\/p>\n\n\n\n<p>\u6267\u884c\u987a\u5e8f\u4e0d\u540c\uff1a\u6240\u6709\u7684\u8bf7\u6c42\u90fd\u662f\u5148\u7ecf\u8fc7\u8fc7\u6ee4\u5668\uff0c\u6700\u540e\u79bb\u5f00\u8fc7\u6ee4\u5668\uff0c\u4e2d\u95f4\u6267\u884c\u7684\u62e6\u622a\u5668\u7684\u65b9\u6cd5\u3002\u62e6\u622a\u5668\u662f\u5728dispatcherservlet\u8fd9\u4e2aservlet\u4e2d\u6267\u884c\u7684\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"335\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-1024x335.png\" alt=\"\" class=\"wp-image-14882\" style=\"width:634px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-1024x335.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-300x98.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-768x251.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-1536x502.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-830x271.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-230x75.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-350x114.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282-480x157.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-282.png 1616w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>SpringMVC\u62e6\u622a\u5668\u5904\u7406\u6d41\u7a0b\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"362\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-1024x362.png\" alt=\"\" class=\"wp-image-14883\" style=\"width:614px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-1024x362.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-300x106.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-768x272.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-1536x543.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-830x294.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-230x81.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-350x124.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283-480x170.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-283.png 1628w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u62e6\u622a\u5668\u4e0e\u8fc7\u6ee4\u5668\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<ul>\n<li>1 \u62e6\u622a\u5668\u662f\u57fa\u4e8ejava\u7684\u53cd\u5c04\u673a\u5236\u7684\uff0c\u800c\u8fc7\u6ee4\u5668\u662f\u57fa\u4e8e\u51fd\u6570\u56de\u8c03\u3002<\/li>\n\n\n\n<li>2 \u8fc7\u6ee4\u5668\u662fservlet\u89c4\u8303\u89c4\u5b9a\u7684\uff0c\u53ea\u80fd\u7528\u4e8eweb\u7a0b\u5e8f\u4e2d\uff0c\u800c\u62e6\u622a\u5668\u662f\u5728spring\u5bb9\u5668\u4e2d\uff0c\u5b83\u4e0d\u4f9d\u8d56servlet\u5bb9\u5668\u3002<\/li>\n\n\n\n<li>3 \u8fc7\u6ee4\u5668\u53ef\u4ee5\u62e6\u622a\u51e0\u4e4e\u6240\u6709\u7684\u8bf7\u6c42(\u5305\u542b\u5bf9\u9759\u6001\u8d44\u6e90\u7684\u8bf7\u6c42)\uff0c\u800c\u62e6\u622a\u5668\u53ea\u62e6\u622aaction\u8bf7\u6c42(\u4e0d\u62e6\u622a\u9759\u6001\u8d44\u6e90\u8bf7\u6c42)\u3002<\/li>\n\n\n\n<li>4 \u62e6\u622a\u5668\u53ef\u4ee5\u8bbf\u95eeaction\u4e0a\u4e0b\u6587\u3001\u503c\u6808\u91cc\u7684\u5bf9\u8c61\uff0c\u800c\u8fc7\u6ee4\u5668\u4e0d\u80fd\u8bbf\u95ee\u3002<\/li>\n\n\n\n<li>5 \u5728action\u7684\u751f\u547d\u5468\u671f\u4e2d\uff0c\u62e6\u622a\u5668\u53ef\u4ee5\u591a\u6b21\u88ab\u8c03\u7528\uff0c\u800c\u8fc7\u6ee4\u5668\u53ea\u80fd\u5728\u5bb9\u5668\u521d\u59cb\u5316\u65f6\u88ab\u8c03\u7528\u4e00\u6b21\u3002<\/li>\n\n\n\n<li>6 \u62e6\u622a\u5668\u53ef\u4ee5\u83b7\u53d6IOC\u5bb9\u5668\u4e2d\u7684\u5404\u4e2abean\uff0c\u800c\u8fc7\u6ee4\u5668\u5c31\u4e0d\u884c\uff0c\u8fd9\u70b9\u5f88\u91cd\u8981\uff0c\u5728\u62e6\u622a\u5668\u91cc\u6ce8\u5165\u4e00\u4e2aservice\uff0c\u53ef\u4ee5\u8c03\u7528\u4e1a\u52a1\u903b\u8f91\u3002<\/li>\n\n\n\n<li>7 \u62e6\u622a\u5668\u662f\u88ab\u5305\u88f9\u5728\u8fc7\u6ee4\u5668\u4e4b\u4e2d\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u5f00\u53d1\u4e86\u5f88\u4e45\u7684web\u670d\u52a1\uff0c\u4f7f\u7528\u4e86\u5f88\u591aweb\u6846\u67b6\uff0c\u90fd\u5fd8\u8bb0web\u6280\u672f\u6700\u539f\u59cb\u7684\u6a21\u6837\u4e86\uff0c\u4eca\u5929\u6765\u56de\u987e\u4e0b\u3002 \u9996\u5148\u56de\u5fc6\u4e0b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14871"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14871"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14871\/revisions"}],"predecessor-version":[{"id":14885,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14871\/revisions\/14885"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}