{"id":622,"date":"2015-05-06T10:12:33","date_gmt":"2015-05-06T02:12:33","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=622"},"modified":"2026-08-18T11:16:10","modified_gmt":"2026-08-18T03:16:10","slug":"servlet%e6%a6%82%e8%bf%b0","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=622","title":{"rendered":"Servlet\u6982\u8ff0"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">Servlet \u662f\u4e00\u79cd\u72ec\u7acb\u4e8e\u5e73\u53f0\u548c\u534f\u8bae\u7684<strong style=\"color: #4870ac;\">\u670d\u52a1\u5668\u7aef Java \u5e94\u7528\u7a0b\u5e8f<\/strong>\uff0c\u7528\u6765\u751f\u6210\u52a8\u6001 Web \u9875\u9762\u3002\u5b83\u4e0d\u4ece\u547d\u4ee4\u884c\u542f\u52a8\uff0c\u800c\u662f\u7531 Web \u670d\u52a1\u5668\u52a0\u8f7d\uff1b\u8fd9\u53f0\u670d\u52a1\u5668\u5fc5\u987b\u5305\u542b\u652f\u6301 Servlet \u7684 Java \u865a\u62df\u673a\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u548c Applet \u4e00\u6837\uff0cServlet \u6ca1\u6709 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">main()<\/code>\uff0c\u751f\u547d\u5468\u671f\u7531\u5bb9\u5668\u8c03\u7528\uff1b\u548c JSP \u76f8\u6bd4\uff0cJSP \u53ea\u662f\u628a\u9759\u6001 HTML \u5199\u8d77\u6765\u66f4\u65b9\u4fbf\uff0c\u672c\u8d28\u80fd\u529b\u5e76\u6ca1\u6709\u8d85\u51fa Servlet\u3002<\/p>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\">\u5199 HTTP Servlet \u65f6\uff0c\u901a\u5e38\u6269\u5c55 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">HttpServlet<\/code>\uff0c\u8986\u76d6 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doGet()<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doPost()<\/code>\uff0c\u5e76\u5728 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">init()<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">destroy()<\/code> \u91cc\u7ba1\u7406\u4e00\u6b21\u6027\u8d44\u6e90\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u6982\u8ff0<\/h2>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3498\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" width=\"2151\" height=\"1105\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png 2151w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-768x395.png 768w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-1536x789.png 1536w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-2048x1052.png 2048w\" sizes=\"(max-width: 2151px) 100vw, 2151px\" \/><\/a><\/p>\n<p style=\"margin: 1em 0px;\">Servlet \u4f4d\u4e8e Web \u670d\u52a1\u5668\u5185\u90e8\u3002\u5bb9\u5668\u8d1f\u8d23\u88c5\u5165\u3001\u521d\u59cb\u5316\u3001\u628a\u8bf7\u6c42\u6d3e\u5230\u5bf9\u5e94\u65b9\u6cd5\uff0c\u5e76\u5728\u5378\u8f7d\u65f6\u505a\u6e05\u7406\u3002\u5148\u628a\u5b83\u548c\u666e\u901a Java \u7a0b\u5e8f\u3001Applet\u3001JSP \u653e\u5728\u4e00\u5f20\u8868\u91cc\u5bf9\u7167\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5bf9\u6bd4\u9879<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u666e\u901a Java \u7a0b\u5e8f<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">Applet<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">Servlet<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5165\u53e3<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6709 main()<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u65e0 main()\uff0c\u7531\u6d4f\u89c8\u5668\/\u5bb9\u5668\u8c03\u7528<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u65e0 main()\uff0c\u7531 Servlet \u5bb9\u5668\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8fd0\u884c\u4f4d\u7f6e<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u672c\u673a\u72ec\u7acb\u8fdb\u7a0b<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5ba2\u6237\u7aef\uff0c\u968f\u6d4f\u89c8\u5668<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u670d\u52a1\u5668\u7aef<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u56fe\u5f62\u754c\u9762<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u53ef\u9009<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">AWT\/\u56fe\u5f62\u754c\u9762<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6ca1\u6709\u56fe\u5f62\u754c\u9762<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u751f\u547d\u5468\u671f<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u81ea\u5df1\u7ba1<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">init() \/ destroy()<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">init() \/ service() \/ destroy()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u548c JSP \u7684\u5173\u7cfb<\/h3>\n<p style=\"margin: 1em 0px;\">JSP\uff08JavaServer Pages\uff09\u628a\u9759\u6001 HTML \u548c\u52a8\u6001\u5185\u5bb9\u6df7\u5728\u4e00\u4e2a\u9875\u9762\u91cc\u5199\u3002\u5b83\u5e76\u6ca1\u6709\u589e\u52a0\u4efb\u4f55\u672c\u8d28\u4e0a\u4e0d\u80fd\u7528 Servlet \u5b9e\u73b0\u7684\u529f\u80fd\uff0c\u53ea\u662f\u4e0d\u5fc5\u518d\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">println<\/code> \u8f93\u51fa\u6bcf\u4e00\u884c HTML\u3002\u5185\u5bb9\u548c\u5916\u89c2\u53ef\u4ee5\u5206\u5f00\uff1a\u9875\u9762\u8bbe\u8ba1\u8005\u5199 HTML\uff0c\u7a0b\u5e8f\u5458\u5728\u9884\u7559\u4f4d\u7f6e\u63d2\u5165\u52a8\u6001\u7ed3\u679c\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001HTTP Servlet \u7f16\u7a0b\u63a5\u53e3<\/h2>\n<p style=\"margin: 1em 0px;\">\u8981\u521b\u5efa HTTP Servlet\uff0c\u8bf7\u6269\u5c55 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">javax.servlet.http.HttpServlet<\/code>\u3002\u8fd9\u4e2a\u7c7b\u63d0\u4f9b <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">init()<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">destroy()<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code> \u7b49\u65b9\u6cd5\u3002HTML \u8868\u5355\u63d0\u4ea4\u65f6\uff0c\u4f1a\u6307\u5b9a\u670d\u52a1\u5668\u5e94\u6267\u884c\u54ea\u4e00\u4e2a Servlet\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. init()<\/h3>\n<p style=\"margin: 1em 0px;\">\u5728 Servlet \u7684\u751f\u547d\u671f\u4e2d\uff0c<strong style=\"color: #4870ac;\">\u53ea\u6267\u884c\u4e00\u6b21<\/strong>\u3002\u53ef\u4ee5\u914d\u7f6e\u6210\u670d\u52a1\u5668\u542f\u52a8\u65f6\u88c5\u5165\uff0c\u6216\u5ba2\u6237\u7b2c\u4e00\u6b21\u8bbf\u95ee\u65f6\u88c5\u5165\u3002\u65e0\u8bba\u6709\u591a\u5c11\u5ba2\u6237\u8bbf\u95ee\uff0c\u90fd\u4e0d\u4f1a\u91cd\u590d\u6267\u884c\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u7f3a\u7701\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">init()<\/code> \u901a\u5e38\u591f\u7528\u3002\u8986\u76d6\u5b83\u65f6\uff0c\u5178\u578b\u7528\u9014\u662f\u7ba1\u7406\u670d\u52a1\u5668\u7aef\u8d44\u6e90\uff1a\u4e00\u6b21\u6027\u88c5\u5165 GIF \u56fe\u7247\u3001\u521d\u59cb\u5316\u6570\u636e\u5e93\u8fde\u63a5\u3002\u8986\u76d6\u5e26 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ServletConfig<\/code> \u53c2\u6570\u7684\u7248\u672c\u65f6\uff0c\u5e94\u8c03\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">super.init(config)<\/code>\uff0c\u5426\u5219\u521d\u59cb\u5316\u53c2\u6570\u548c\u914d\u7f6e\u4f1a\u4e22\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code> \u88ab\u8c03\u7528\u4e4b\u524d\uff0c\u5fc5\u987b\u4fdd\u8bc1 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">init()<\/code> \u5df2\u7ecf\u5b8c\u6210\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. service()<\/h3>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code> \u662f Servlet \u7684\u6838\u5fc3\u3002\u6bcf\u6b21\u5ba2\u6237\u8bf7\u6c42\u4e00\u4e2a HttpServlet \u5bf9\u8c61\uff0c\u5c31\u4f1a\u8c03\u7528\u5b83\uff0c\u5e76\u4f20\u5165\u8bf7\u6c42\u5bf9\u8c61\u548c\u54cd\u5e94\u5bf9\u8c61\u3002HttpServlet \u91cc\u5df2\u6709\u5b9e\u73b0\uff1a\u7f3a\u7701\u4f1a\u6309 HTTP \u65b9\u6cd5\u5206\u53d1\u5230 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doGet()<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doPost()<\/code> \u7b49\u3002\u4e00\u822c\u4e0d\u5fc5\u8986\u76d6 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code>\uff0c\u8986\u76d6\u5bf9\u5e94\u7684 do \u65b9\u6cd5\u5373\u53ef\u3002<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>POST\uff1a\u8868\u5355\u63d0\u4ea4\u3001\u4f1a\u4fee\u6539\u670d\u52a1\u5668\u7aef\u6570\u636e\u65f6\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doPost()<\/code>\uff0c\u53c2\u6570\u5728\u8bf7\u6c42\u4f53\u91cc\u3002<\/section>\n<\/li>\n<li>\n<section>GET\uff1a\u76f4\u63a5\u8bbf\u95ee URL\u3001\u53ea\u8bfb\u67e5\u8be2\u65f6\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doGet()<\/code>\uff0c\u53c2\u6570\u8ddf\u5728 URL \u540e\u9762\u3002<\/section>\n<\/li>\n<li>\n<section>\u54cd\u5e94\u53ef\u4ee5\u662f\u8f93\u51fa\u6d41\uff08\u6d4f\u89c8\u5668\u6309 content-type \u89e3\u91ca\uff09\u3001HTTP \u9519\u8bef\uff0c\u6216\u91cd\u5b9a\u5411\u5230\u53e6\u4e00\u4e2a URL \/ Servlet \/ JSP\u3002<\/section>\n<\/li>\n<\/ul>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">3. destroy()<\/h3>\n<p style=\"margin: 1em 0px;\">\u53ea\u6267\u884c\u4e00\u6b21\uff1a\u670d\u52a1\u5668\u505c\u6b62\u5e76\u5378\u88c5 Servlet \u65f6\u8c03\u7528\u3002\u53ef\u7528\u6765\u4fdd\u5b58\u7edf\u8ba1\u6570\u636e\u3001\u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\u3002\u5bb9\u5668\u4f1a\u7b49\u5230\u6240\u6709 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code> \u5b8c\u6210\uff0c\u6216\u8d85\u8fc7\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u540e\u518d\u8c03\u7528\u3002\u5982\u679c service \u91cc\u8fd8\u6d3e\u751f\u4e86\u522b\u7684\u7ebf\u7a0b\uff0c\u8c03\u7528 destroy \u524d\u8981\u786e\u8ba4\u5b83\u4eec\u5df2\u7ecf\u7ed3\u675f\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">4. getServletConfig() \/ getServletInfo()<\/h3>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">getServletConfig()<\/code> \u8fd4\u56de <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ServletConfig<\/code>\uff0c\u7528\u6765\u8bfb\u53d6\u521d\u59cb\u5316\u53c2\u6570\u548c <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ServletContext<\/code>\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">getServletInfo()<\/code> \u53ef\u9009\uff0c\u7528\u6765\u8fd4\u56de\u4f5c\u8005\u3001\u7248\u672c\u3001\u7248\u6743\u7b49\u4fe1\u606f\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5bb9\u5668\u8c03\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">service()<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doGet()<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">doPost()<\/code> \u65f6\uff0c\u90fd\u4f1a\u4f20\u5165\u8bf7\u6c42\u548c\u54cd\u5e94\u5bf9\u8c61\u3002\u901a\u7528\u5305\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ServletRequest<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">ServletResponse<\/code>\uff0cHTTP \u5305\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">HttpServletRequest<\/code> \/ <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">HttpServletResponse<\/code>\u3002Servlet \u901a\u8fc7\u5b83\u4eec\u4e86\u89e3\u5ba2\u6237\u7aef\u548c\u73af\u5883\uff0c\u5e76\u628a\u7ed3\u679c\u5199\u56de\u6d4f\u89c8\u5668\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001Servlet \u4e3b\u8981\u4efb\u52a1<\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u8bfb\u53d6\u5ba2\u6237\u7aef\u663e\u5f0f\u6570\u636e\uff1aHTML \u8868\u5355\u5b57\u6bb5\u3002<\/section>\n<\/li>\n<li>\n<section>\u8bfb\u53d6\u9690\u5f0f HTTP \u8bf7\u6c42\u6570\u636e\uff1aCookie\u3001\u5a92\u4f53\u7c7b\u578b\u3001\u6d4f\u89c8\u5668\u80fd\u7406\u89e3\u7684\u538b\u7f29\u683c\u5f0f\u7b49\u3002<\/section>\n<\/li>\n<li>\n<section>\u5904\u7406\u6570\u636e\u5e76\u751f\u6210\u7ed3\u679c\uff1a\u8bbf\u95ee\u6570\u636e\u5e93\u3001\u8c03\u7528 Web \u670d\u52a1\uff0c\u6216\u76f4\u63a5\u8ba1\u7b97\u3002<\/section>\n<\/li>\n<li>\n<section>\u53d1\u9001\u663e\u5f0f\u6587\u6863\uff1aHTML \/ XML\u3001\u4e8c\u8fdb\u5236\u56fe\u7247\u3001Excel \u7b49\u3002<\/section>\n<\/li>\n<li>\n<section>\u53d1\u9001\u9690\u5f0f HTTP \u54cd\u5e94\uff1aContent-Type\u3001Cookie\u3001\u7f13\u5b58\u53c2\u6570\u7b49\u3002<\/section>\n<\/li>\n<\/ul>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001\u6b63\u786e\u8ba4\u8bc6 Servlet<\/h2>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. Servlet \u4e0d\u53ef\u4ee5\u72ec\u7acb\u8fd0\u884c<\/h3>\n<p style=\"margin: 1em 0px;\">\u5fc5\u987b\u8fd0\u884c\u5728 Servlet \u5bb9\u5668\u4e2d\uff0c\u7531\u5bb9\u5668\u6267\u884c\u751f\u547d\u5468\u671f\u65b9\u6cd5\uff0c\u56e0\u6b64\u4e0d\u9700\u8981 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">main()<\/code>\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. Servlet \u4e0d\u662f\u7ebf\u7a0b<\/h3>\n<p style=\"margin: 1em 0px;\">\u5b83\u662f\u5b9e\u73b0\u4e86 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Servlet<\/code> \u63a5\u53e3\u7684\u666e\u901a Java \u5bf9\u8c61\uff0c\u5e76\u4e0d\u7ee7\u627f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Thread<\/code>\u3002\u670d\u52a1\u5668\u6536\u5230\u8bf7\u6c42\u65f6\uff0c\u4f1a\u5728\u4e00\u4e2a\u5355\u72ec\u7684\u7ebf\u7a0b\u91cc\u6267\u884c Servlet \u7684\u65b9\u6cd5\uff1b\u540c\u4e00\u4e2a\u5b9e\u4f8b\u53ef\u80fd\u88ab\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8c03\u7528\uff0c\u5171\u4eab\u5b57\u6bb5\u65f6\u8981\u81ea\u5df1\u5904\u7406\u5e76\u53d1\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e94\u3001Web \u670d\u52a1\u5668\u548c Servlet \u5bb9\u5668<\/h2>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. Web \u670d\u52a1\u5668<\/h3>\n<p style=\"margin: 1em 0px;\">Web Server \u662f\u4e92\u8054\u7f51\u4e0a\u90e8\u7f72\u4e86\u7cfb\u7edf\u8f6f\u4ef6\u548c\u5171\u4eab\u8d44\u6e90\u7684\u673a\u5668\u3002\u5ba2\u6237\u7aef\u901a\u8fc7 HTTP \u8bbf\u95ee\u8fd9\u4e9b\u8d44\u6e90\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. Servlet \u5bb9\u5668<\/h3>\n<p style=\"margin: 1em 0px;\">Servlet Container \u662f Web \u670d\u52a1\u5668\u6216\u5e94\u7528\u670d\u52a1\u5668\u7684\u7ec4\u6210\u90e8\u5206\uff1a\u4e3a Servlet \u63d0\u4f9b\u8bf7\u6c42\/\u54cd\u5e94\u670d\u52a1\uff0c\u7ba1\u7406\u751f\u547d\u5468\u671f\uff0c\u8fd8\u53ef\u4ee5\u63d0\u4f9b\u8d44\u6e90\u3001\u5b89\u5168\u3001\u7ebf\u7a0b\u7b49\u670d\u52a1\u3002\u5b83\u53ef\u4ee5\u96c6\u6210\u8fdb\u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u72ec\u7acb\u7a0b\u5e8f\u5d4c\u5165\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">3. Servlet \u6d41\u7a0b<\/h3>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/05\/webserver1.jpg\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1782\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2015\/05\/webserver1.jpg\" alt=\"webserver1\" width=\"679\" height=\"464\" \/><\/a><\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aServlet \u662f\u5bb9\u5668\u91cc\u7684\u666e\u901a Java \u5bf9\u8c61\uff1ainit \u4e00\u6b21\u3001\u8bf7\u6c42\u8fdb\u7ebf\u7a0b\u8c03 service\u3001\u5378\u88c5\u65f6 destroy\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Servlet \u662f\u4e00\u79cd\u72ec\u7acb\u4e8e\u5e73\u53f0\u548c\u534f\u8bae\u7684\u670d\u52a1\u5668\u7aef Java \u5e94\u7528\u7a0b\u5e8f\uff0c\u7528\u6765\u751f\u6210\u52a8\u6001 Web \u9875\u9762\u3002\u5b83\u4e0d\u4ece\u547d\u4ee4\u884c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[183,182],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/622"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=622"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":3539,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/622\/revisions\/3539"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}