{"id":1819,"date":"2016-12-20T11:43:03","date_gmt":"2016-12-20T03:43:03","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1819"},"modified":"2026-08-18T10:04:25","modified_gmt":"2026-08-18T02:04:25","slug":"%e8%a1%a8%e5%8d%95%e6%8f%90%e4%ba%a4%e4%b8%8e%e5%a4%b4%e5%83%8f%e4%b8%8a%e4%bc%a0","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1819","title":{"rendered":"\u8868\u5355\u63d0\u4ea4\u4e0e\u5934\u50cf\u4e0a\u4f20"},"content":{"rendered":"<section id=\"wenyan\" data-provider=\"WenYan\" style=\"font-family: system-ui, &quot;Apple Color Emoji&quot;, &quot;Segoe UI&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Sans&quot;, Roboto, sans-serif; word-break: break-word; overflow-wrap: break-word; color: rgb(0, 0, 0); font-size: 16px; line-height: 1.75; caret-color: rgb(0, 0, 0);\">\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5728 Web \u540e\u53f0\u7ba1\u7406\u7cfb\u7edf\u91cc\uff0c\u6570\u636e\u7684<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u589e\u3001\u5220\u3001\u6539<\/strong>\u51e0\u4e4e\u662f\u6807\u914d\uff0c\u672c\u8d28\u90fd\u662f\u5bf9\u6570\u636e\u5e93\u8868\u8bb0\u5f55\u7684\u64cd\u4f5c\u7528\u6237\u754c\u9762\u3002\u5f53\u64cd\u4f5c\u7684\u6570\u636e\u91cc\u5305\u542b<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5934\u50cf\u56fe\u7247<\/strong>\u65f6\uff0c\u4e8b\u60c5\u5c31\u591a\u4e86\u4e00\u73af\u2014\u2014\u6587\u4ef6\u4e0a\u4f20\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u8fd9\u7bc7\u4ece&#8221;\u4e00\u6b21\u63d0\u4ea4\u5230\u5e95\u53d1\u4e86\u4ec0\u4e48&#8221;\u8bb2\u8d77\uff0c\u518d\u5bf9\u6bd4\u51e0\u79cd\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6700\u540e\u7528&#8221;\u5b66\u751f\u5934\u50cf\u4e0a\u4f20&#8221;\u7684\u5b8c\u6574\u5b9e\u4f8b\u628a\u524d\u540e\u7aef\u4e32\u8d77\u6765\uff0c\u5e76\u8865\u4e0a\u73b0\u4ee3\u5199\u6cd5\u548c\u4f60\u5fc5\u987b\u6ce8\u610f\u7684\u5b89\u5168\u5751\u3002<\/p>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4e00\u3001\u6587\u4ef6\u4e0a\u4f20\u7684\u5e95\u5c42\u539f\u7406<\/span><\/h2>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">1. \u4e00\u6b21\u8bf7\u6c42\uff0c\u672c\u8d28\u662f\u53d1\u9001\u4e00\u6bb5\u6587\u672c<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u5f53\u6d4f\u89c8\u5668\u5411\u670d\u52a1\u5668\u53d1\u4e00\u6b21\u8bf7\u6c42\uff0c\u672c\u8d28\u4e0a\u5c31\u662f<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u53d1\u9001\u4e00\u6bb5\u6309 HTTP \u534f\u8bae\u683c\u5f0f\u7ec4\u88c5\u7684\u6587\u672c\u6570\u636e<\/strong>\u3002\u666e\u901a\u8868\u5355\u63d0\u4ea4\u662f <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">application\/x-www-form-urlencoded<\/code>\uff0c\u800c\u4e00\u65e6\u8868\u5355\u91cc\u8981\u5e26\u6587\u4ef6\uff0c\u5c31\u5fc5\u987b\u6539\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">multipart\/form-data<\/code>\u2014\u2014\u5b83\u4f1a\u628a\u6bcf\u4e2a\u5b57\u6bb5\uff08\u5305\u62ec\u6587\u4ef6\uff09\u7528&#8221;\u5206\u9694\u7b26\uff08boundary\uff09&#8221;\u5207\u6210\u4e00\u6bb5\u4e00\u6bb5\u3002<\/p>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\">\u539f\u6587\u5bf9 HTTP \u8bf7\u6c42\u683c\u5f0f\u6709\u914d\u56fe\uff0c\u62a5\u6587\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<\/blockquote>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><img decoding=\"async\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2016\/12\/requesthttp.jpg\" alt=\"HTTP \u8bf7\u6c42\u62a5\u6587\u683c\u5f0f\" title=\"HTTP \u8bf7\u6c42\u62a5\u6587\u683c\u5f0f\" style=\"max-width: 100%; margin: 0px auto; display: block;\"><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4e0b\u9762\u7528\u4e00\u6bb5 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">multipart\/form-data<\/code> \u8bf7\u6c42\u4f53\u5e2e\u4f60\u518d\u770b\u6e05\u7ed3\u6784\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\">POST \/addStudentServlet.do HTTP\/1.1\nHost: localhost\nContent-Type: multipart\/form-data; boundary=----WebKitFormBoundaryABC123\n\n------WebKitFormBoundaryABC123\nContent-Disposition: form-data; name=\"userName\"\n\n\u5f20\u4e09\n------WebKitFormBoundaryABC123\nContent-Disposition: form-data; name=\"number\"\n\n2021001\n------WebKitFormBoundaryABC123\nContent-Disposition: form-data; name=\"headerImg\"; filename=\"avatar.png\"\nContent-Type: image\/png\n\n&lt;\u8fd9\u91cc\u662f\u5934\u50cf\u6587\u4ef6\u7684\u4e8c\u8fdb\u5236\u6570\u636e&gt;\n------WebKitFormBoundaryABC123--\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u6ce8\u610f\u4e09\u70b9\uff1a<\/p>\n<ul style=\"margin: 8px 0px; padding-left: 28px; list-style: outside disc;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u666e\u901a\u6587\u672c\u5b57\u6bb5\uff08userName\u3001number\uff09\u548c\u6587\u4ef6\u5b57\u6bb5\uff08headerImg\uff09\u88ab\u540c\u4e00\u4e2a boundary \u9694\u5f00\uff1b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u6587\u4ef6\u5b57\u6bb5\u989d\u5916\u5e26 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">filename<\/code> \u548c <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">Content-Type<\/code>\uff1b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u6587\u4ef6\u5185\u5bb9\u5c31\u662f<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u539f\u59cb\u4e8c\u8fdb\u5236\u6d41<\/strong>\uff0c\u670d\u52a1\u5668\u8981\u6309\u8fd9\u4e2a\u683c\u5f0f\u628a\u5b83&#8221;\u5207&#8221;\u51fa\u6765\u3001\u518d\u5199\u5230\u78c1\u76d8\u3002<\/section>\n<\/li>\n<\/ul>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">2. \u4e0a\u4f20 = \u6309\u683c\u5f0f\u8bfb + io \u6d41\u5199\u6587\u4ef6<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u6240\u4ee5&#8221;\u81ea\u5df1\u5b9e\u73b0\u4e0a\u4f20&#8221;\u7684\u601d\u8def\u5f88\u6734\u7d20\uff1a\u6309 HTTP \u534f\u8bae\u683c\u5f0f\u628a\u8bf7\u6c42\u4f53\u8bfb\u51fa\u6765\uff0c\u627e\u5230\u6587\u4ef6\u90a3\u6bb5\u4e8c\u8fdb\u5236\uff0c\u7528 IO \u6d41 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">write<\/code> \u5230\u670d\u52a1\u5668\u78c1\u76d8\u3002\u96be\u70b9\u5728\u4e8e\u89e3\u6790\u683c\u5f0f\u7e41\u7410\u3001\u8fb9\u754c\u60c5\u51b5\u591a\u2014\u2014\u6240\u4ee5\u751f\u4ea7\u73af\u5883\u90fd\u7528\u73b0\u6210\u5e93\u3002<\/p>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4e8c\u3001\u4e09\u79cd\u5b9e\u73b0\u65b9\u5f0f\u5bf9\u6bd4<\/span><\/h2>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: rgb(255, 249, 235); color: rgb(51, 51, 51); text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u65b9\u5f0f<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u601d\u8def<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u73b0\u72b6<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u2460 \u81ea\u5df1\u89e3\u6790 HTTP<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u624b\u52a8\u8bfb\u6d41\u3001\u5207 boundary\u3001\u5199\u6587\u4ef6<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u9002\u5408\u7406\u89e3\u539f\u7406\uff0c\u751f\u4ea7\u4e0d\u63a8\u8350<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u2461 SmartUpload \u5e93<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u4e00\u884c <code>su.upload()<\/code> \u641e\u5b9a<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5df2\u505c\u6b62\u7ef4\u62a4<\/strong>\uff0c\u4ec5\u5386\u53f2\u9879\u76ee\u53ef\u89c1<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u2462 commons-fileupload<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">Apache \u7ec4\u4ef6\uff0c\u89e3\u6790\u5c01\u88c5\u5230 <code>FileItem<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u7ecf\u5178\u4f46 <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5df2 EOL\uff082021 \u8d77\u5e9f\u5f03\uff09<\/strong>\uff0c\u65b0\u9879\u76ee\u7528 Servlet 3.0+<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">1. \u81ea\u5df1\u89e3\u6790\u5b9e\u73b0<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u7528\u5230\u4e24\u5757\u77e5\u8bc6\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">HTTP \u534f\u8bae<\/strong>\uff08\u6309\u4e0a\u9762\u683c\u5f0f\u7ec4\u88c5\/\u62c6\u89e3\u8bf7\u6c42\uff09+ <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">IO \u6d41<\/strong>\uff08\u628a\u8bfb\u5230\u7684\u5934\u50cf\u4e8c\u8fdb\u5236\u5199\u6587\u4ef6\uff09\u3002\u7406\u89e3\u4e86\u5b83\uff0c\u4f60\u5c31\u660e\u767d&#8221;\u4e0a\u4f20&#8221;\u6ca1\u6709\u4efb\u4f55\u9b54\u6cd5\u3002<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">2. SmartUpload \u4e0a\u4f20\u5e93<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u65e9\u5e74\u5f88\u6d41\u884c\uff0c\u51e0\u884c\u4ee3\u7801\u5c31\u80fd\u4e0a\u4f20\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">SmartUpload<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">su<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">SmartUpload<\/span>();\nsu.initialize(getServletConfig(), req, resp); <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u521d\u59cb\u5316\u5bf9\u8c61<\/span>\nsu.upload();                  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u4e0a\u4f20\u6587\u4ef6<\/span>\nsu.save(file);                <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u4fdd\u5b58\u6587\u4ef6<\/span>\n<\/code><\/pre>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u6ce8\u8bb0<\/strong>\uff1aSmartUpload \u65e9\u5df2\u505c\u6b62\u7ef4\u62a4\uff0c\u4e14\u5bf9\u4e2d\u6587\u3001\u5927\u6587\u4ef6\u652f\u6301\u5dee\uff0c\u73b0\u4ee3\u9879\u76ee\u4e0d\u8981\u518d\u7528\u3002<\/p>\n<\/blockquote>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">3. commons-fileupload \u4e0a\u4f20\u5e93\uff08\u7ecf\u5178\u65b9\u6848\uff09<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4e0b\u8f7d <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">commons-fileupload-x.x.jar<\/code> \u548c `commons-io-x.x.jar\uff08<a href=\"http:\/\/commons.apache.org\/proper\/commons-fileupload\/download_fileupload.cgi\" style=\"text-decoration: none; color: rgb(87, 107, 149); border-bottom: 1px solid rgba(87, 107, 149, 0.3);\">\u5730\u5740<\/a>\uff09\uff0c\u6838\u5fc3\u5c31\u4e24\u4e2a\u7c7b\u3002<\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u2460 \u6587\u4ef6\u9879\u76ee\u5de5\u5382 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">DiskFileItemFactory<\/code><\/strong><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u51b3\u5b9a&#8221;\u5c0f\u6587\u4ef6\u653e\u5185\u5b58\u3001\u5927\u6587\u4ef6\u843d\u4e34\u65f6\u76d8&#8221;\uff1a<\/p>\n<ul style=\"margin: 8px 0px; padding-left: 28px; list-style: outside disc;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">DiskFileItemFactory()<\/code>\uff1a\u9ed8\u8ba4 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">sizeThreshold = 10KB<\/code>\uff0c\u8d85\u8fc7\u5219\u5b58\u5230\u4e34\u65f6\u76ee\u5f55\uff08<code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">System.getProperty(\"java.io.tmpdir\")<\/code> \u83b7\u53d6\uff09\uff1b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">DiskFileItemFactory(int sizeThreshold, File repository)<\/code>\uff1a\u53ef\u81ea\u5b9a\u4e49\u9608\u503c\u548c\u4e34\u65f6\u76ee\u5f55\u8def\u5f84\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u2461 \u8bf7\u6c42\u89e3\u6790\u7c7b <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">ServletFileUpload<\/code><\/strong><\/p>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u628a\u4e0a\u4f20\u8bf7\u6c42\u89e3\u6790\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">List&lt;FileItem&gt;<\/code>\uff0c\u6bcf\u4e2a <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">FileItem<\/code> \u5c31\u662f\u8868\u5355\u91cc\u7684\u4e00\u4e2a\u5b57\u6bb5\uff08\u6587\u672c\u6216\u6587\u4ef6\uff09\u3002\u5173\u952e\u8bbe\u7f6e\uff1a<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: rgb(255, 249, 235); color: rgb(51, 51, 51); text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u65b9\u6cd5<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u4f5c\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><code>setHeaderEncoding(\"UTF-8\")<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u8bfb\u53d6\u8bf7\u6c42\u5934\u7528\u7684\u7f16\u7801\uff0c\u9632\u4e2d\u6587\u4e71\u7801<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><code>setSizeMax(long)<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u5355\u6b21\u8bf7\u6c42\u603b\u5927\u5c0f\u4e0a\u9650\uff0c\u9ed8\u8ba4 -1 \u4e0d\u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><code>setFileSizeMax(long)<\/code><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u5355\u4e2a\u6587\u4ef6\u5927\u5c0f\u4e0a\u9650\uff0c\u9ed8\u8ba4 -1 \u4e0d\u9650\u5236<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">ServletFileUpload<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">sfu<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">ServletFileUpload<\/span>(factory);\nsfu.setHeaderEncoding(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"UTF-8\"<\/span>);\nList&lt;FileItem&gt; items = sfu.parseRequest(req);\n<\/code><\/pre>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u6ce8\u8bb0<\/strong>\uff1aApache \u5df2\u4e8e 2021 \u5e74\u5ba3\u5e03 commons-fileupload <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u505c\u6b62\u7ef4\u62a4\uff08EOL\uff09<\/strong>\uff0c\u5e76\u5efa\u8bae\u8fc1\u79fb\u5230 Servlet 3.0 \u5185\u7f6e\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">Part<\/code> API \u6216\u6846\u67b6\u5c01\u88c5\u3002\u4e0b\u9762\u7684\u5b9e\u4f8b\u4fdd\u7559\u5176\u5199\u6cd5\u4ee5\u4fbf\u8bfb\u8001\u4ee3\u7801\uff0c\u73b0\u4ee3\u5199\u6cd5\u89c1\u7b2c\u516d\u8282\u3002<\/p>\n<\/blockquote>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4e09\u3001\u5b9e\u6218\uff1a\u5b66\u751f\u5934\u50cf\u4e0a\u4f20\u5b9e\u4f8b<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4e0b\u9762\u662f\u4e00\u5957**\u6dfb\u52a0\u5b66\u751f\uff08\u542b\u5934\u50cf\uff09+ \u4fee\u6539\u5b66\u751f\uff08\u6362\u5934\u50cf\u3001\u5220\u65e7\u56fe\uff09**\u7684\u5b8c\u6574\u5b9e\u73b0\uff0c\u903b\u8f91\u6e05\u6670\uff0c\u662f\u7406\u89e3&#8221;\u8868\u5355 + \u6587\u4ef6&#8221;\u6df7\u5408\u63d0\u4ea4\u7684\u597d\u6837\u672c\u3002<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">1. \u6dfb\u52a0\u5b66\u751f<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u524d\u7aef <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">addstudent.jsp<\/code><\/strong> \u2014\u2014 \u5173\u952e\u662f <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">enctype=\"multipart\/form-data\"<\/code>\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-jsp\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\">&lt;div class=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"login-form\"<\/span>&gt;\n  &lt;form action=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\".\/addStudentServlet.do\"<\/span> method=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"post\"<\/span> enctype=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"multipart\/form-data\"<\/span>&gt;\n  &lt;input type=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"text\"<\/span> name=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"userName\"<\/span> placeholder=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u8bf7\u8f93\u5165\u5b66\u751f\u59d3\u540d\"<\/span>&gt;\n  &lt;input type=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"text\"<\/span> name=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"number\"<\/span> placeholder=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u8bf7\u8f93\u5165\u5b66\u751f\u5b66\u53f7\"<\/span>&gt;&lt;br&gt;&lt;br&gt;\n  \u5934\u50cf :&lt;input type=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"file\"<\/span> name=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"headerImg\"<\/span>\/&gt;\n  &lt;input type=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"submit\"<\/span> value=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u6dfb\u52a0\"<\/span>&gt;\n  &lt;\/form&gt;\n&lt;\/div&gt;\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u540e\u7aef Servlet<\/strong> \u2014\u2014 \u628a&#8221;\u89e3\u6790\u8bf7\u6c42&#8221;\u548c&#8221;\u5b58\u6570\u636e\u5e93&#8221;\u62c6\u6210\u4e24\u4e2a\u65b9\u6cd5\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">protected<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">void<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">doPost<\/span><span class=\"hljs-params\">(HttpServletRequest request, HttpServletResponse response)<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> ServletException, IOException {\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u5b58\u653e\u6240\u6709\u8bf7\u6c42\u53c2\u6570\uff08\u6587\u672c + \u6587\u4ef6\u76f8\u5bf9\u8def\u5f84\uff09<\/span>\n  HashMap&lt;String, String&gt; parameterMap = <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">HashMap<\/span>&lt;String, String&gt;();\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u2014\u2014 \u4e0a\u4f20\u5934\u50cf\uff0c\u5e76\u628a\u53c2\u6570\u6536\u8fdb hashMap \u2014\u2014<\/span>\n  uploadHeader(request, parameterMap);\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u2014\u2014 \u5199\u5165\u6570\u636e\u5e93 \u2014\u2014<\/span>\n  addStudent(parameterMap, request, response);\n}\n\n<span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/** \u89e3\u6790\u4e0a\u4f20\u8bf7\u6c42\uff1a\u6587\u672c\u5b57\u6bb5\u5b58\u503c\uff0c\u6587\u4ef6\u5b57\u6bb5\u5199\u76d8\u5e76\u5b58\u8def\u5f84 *\/<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">public<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">void<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">uploadHeader<\/span><span class=\"hljs-params\">(HttpServletRequest request, HashMap&lt;String, String&gt; parameterMap)<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> UnsupportedEncodingException {\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">ServletFileUpload<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">servletFileUpload<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">ServletFileUpload<\/span>(<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">DiskFileItemFactory<\/span>());\n  servletFileUpload.setHeaderEncoding(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"UTF-8\"<\/span>);\n  List&lt;FileItem&gt; fileItemLists = <span class=\"hljs-literal\" style=\"color: rgb(203, 75, 22);\">null<\/span>;\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">try<\/span> {\n    fileItemLists = servletFileUpload.parseRequest(request);\n  } <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">catch<\/span> (FileUploadException e) {\n    e.printStackTrace();\n  }\n  Iterator&lt;FileItem&gt; iterator = fileItemLists.iterator();\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">while<\/span> (iterator.hasNext()) {\n    <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">FileItem<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileItem<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> iterator.next();\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">if<\/span> (fileItem.isFormField()) {         <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u666e\u901a\u6587\u672c\u5b57\u6bb5<\/span>\n      <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fieldName<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> fileItem.getFieldName();\n      <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileValue<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> fileItem.getString(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"UTF-8\"<\/span>);\n      parameterMap.put(fieldName, fileValue);\n    } <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">else<\/span> {                     <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u6587\u4ef6\u5b57\u6bb5<\/span>\n      <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">rootDir<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> getServletContext().getRealPath(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\/\"<\/span>);\n      <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileDir<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"upload\/\"<\/span> + fileItem.getName();\n      <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">File<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">file<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">File<\/span>(rootDir + fileDir);\n      FileUtil.createFile(file);\n      <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">try<\/span> {\n        fileItem.write(file);          <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u5199\u76d8<\/span>\n      } <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">catch<\/span> (Exception e) {\n        e.printStackTrace();\n      }\n      parameterMap.put(fileItem.getFieldName(), fileDir); <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u5b58\u76f8\u5bf9\u8def\u5f84<\/span>\n    }\n  }\n}\n\n<span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/** \u628a\u6536\u96c6\u5230\u7684\u53c2\u6570\u5199\u5165\u6570\u636e\u5e93 *\/<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">private<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">void<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">addStudent<\/span><span class=\"hljs-params\">(HashMap&lt;String, String&gt; parameters,\n    HttpServletRequest request, HttpServletResponse response)<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> ServletException, IOException {\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">userName<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> parameters.get(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"userName\"<\/span>);\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">number<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> parameters.get(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"number\"<\/span>);\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">int<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">numbers<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> Integer.parseInt(number);\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">int<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">ages<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> <span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">23<\/span>;\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileUrl<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> parameters.get(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"headerImg\"<\/span>);\n  System.out.println(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"userName:\"<\/span> + userName + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\", number:\"<\/span> + number + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\", fileUrl:\"<\/span> + fileUrl);\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u8fd9\u91cc\u6267\u884c\u6570\u636e\u5e93 INSERT<\/span>\n}\n<\/code><\/pre>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u6838\u5fc3\u601d\u8def\u4e00\u53e5\u8bdd\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\"><code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">isFormField()<\/code> \u533a\u5206\u6587\u672c\u548c\u6587\u4ef6<\/strong>\u2014\u2014\u6587\u672c\u76f4\u63a5\u53d6\u503c\uff0c\u6587\u4ef6\u5148\u5199\u76d8\u518d\u628a&#8221;\u76f8\u5bf9\u8def\u5f84&#8221;\u5f53\u4f5c\u666e\u901a\u53c2\u6570\u5b58\u8d77\u6765\uff0c\u6700\u540e\u4e00\u8d77\u8fdb\u6570\u636e\u5e93\u3002<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">2. \u4fee\u6539\u5b66\u751f\uff08\u6362\u5934\u50cf\uff09<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4fee\u6539\u6bd4\u6dfb\u52a0\u591a\u4e00\u6b65\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5148\u4e0a\u4f20\u65b0\u5934\u50cf\uff0c\u518d\u5220\u6389\u65e7\u5934\u50cf\uff0c\u6700\u540e\u66f4\u65b0\u6570\u636e\u5e93\u5b57\u6bb5<\/strong>\u3002<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">protected<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">void<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">doPost<\/span><span class=\"hljs-params\">(HttpServletRequest request, HttpServletResponse response)<\/span>\n    <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> ServletException, IOException {\n  HashMap&lt;String, String&gt; parameterMap = <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">HashMap<\/span>&lt;&gt;();\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u2014\u2014 \u4e0a\u4f20\u65b0\u5934\u50cf\uff0c\u53c2\u6570\u6536\u8fdb hashMap \u2014\u2014<\/span>\n  uploadHeader(request, parameterMap);\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u2014\u2014 \u5220\u9664\u539f\u5934\u50cf\u6587\u4ef6 \u2014\u2014<\/span>\n  deleteHeaderImg(parameterMap);\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u2014\u2014 \u66f4\u65b0\u6570\u636e\u5e93\u5b57\u6bb5 \u2014\u2014<\/span>\n  updateStudent(parameterMap);\n  response.sendRedirect(request.getContextPath() + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\/student_list.jsp\"<\/span>);\n}\n<\/code><\/pre>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\">\u987a\u5e8f\u5f88\u91cd\u8981\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5148\u62ff\u5230\u65b0\u56fe\u8def\u5f84\uff0c\u518d\u6839\u636e\u6570\u636e\u5e93\u91cc\u7684\u65e7\u8def\u5f84\u5220\u6587\u4ef6\uff0c\u6700\u540e\u66f4\u65b0\u5b57\u6bb5<\/strong>\u3002\u82e5\u5148\u5220\u518d\u4f20\uff0c\u4e2d\u9014\u5931\u8d25\u5c31\u4f1a&#8221;\u56fe\u6ca1\u4e86\u5b57\u6bb5\u4e5f\u6ca1\u66f4\u65b0&#8221;\u3002<\/p>\n<\/blockquote>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u56db\u3001\u73b0\u4ee3\u5199\u6cd5\uff08\u63a8\u8350\u65b0\u9879\u76ee\u7528\uff09<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u4e0a\u9762\u7684\u5b9e\u4f8b\u662f\u7406\u89e3\u539f\u7406\u7684\u6559\u79d1\u4e66\uff0c\u4f46\u65b0\u9879\u76ee\u8bf7\u7528\u66f4\u7b80\u6d01\u7684\u65b9\u6848\u3002<\/p>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">1. \u540e\u7aef\uff1aServlet 3.0+ \u7684 <code>Part<\/code> API\uff08\u65e0\u9700\u4efb\u4f55\u4e0a\u4f20\u5e93\uff09<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">Servlet 3.0 \u8d77\u5185\u7f6e\u4e86\u6587\u4ef6\u4e0a\u4f20\uff0c\u52a0\u4e00\u4e2a <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">@MultipartConfig<\/code> \u6ce8\u89e3\u5373\u53ef\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@WebServlet(\"\/upload\")<\/span>\n<span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@MultipartConfig(\n  fileSizeThreshold = 1024 * 1024,    \/\/ 1MB \u4ee5\u4e0b\u7559\u5185\u5b58\n  maxFileSize = 5 * 1024 * 1024,    \/\/ \u5355\u6587\u4ef6\u6700\u5927 5MB\n  maxRequestSize = 10 * 1024 * 1024   \/\/ \u5355\u6b21\u8bf7\u6c42\u6700\u5927 10MB\n)<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">public<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">class<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">UploadServlet<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">extends<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">HttpServlet<\/span> {\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">protected<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">void<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">doPost<\/span><span class=\"hljs-params\">(HttpServletRequest req, HttpServletResponse resp)<\/span>\n      <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> IOException, ServletException {\n    <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">userName<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> req.getParameter(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"userName\"<\/span>);   <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u6587\u672c\u7167\u5e38\u53d6<\/span>\n    <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">Part<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">filePart<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> req.getPart(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"headerImg\"<\/span>);      <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u6587\u4ef6\u7528 getPart<\/span>\n    <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileName<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> UUID.randomUUID() + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"_\"<\/span> +\n        filePart.getSubmittedFileName();       <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u91cd\u547d\u540d\u9632\u51b2\u7a81<\/span>\n    <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">saveDir<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> getServletContext().getRealPath(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\/\"<\/span>) + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"upload\/\"<\/span>;\n    filePart.write(saveDir + fileName);\n    <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u628a userName + \"upload\/\" + fileName \u5199\u5e93<\/span>\n  }\n}\n<\/code><\/pre>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">2. \u540e\u7aef\uff1aSpring Boot \u7684 <code>MultipartFile<\/code><\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">Spring \u9879\u76ee\u66f4\u76f4\u63a5\uff0c\u53c2\u6570\u76f4\u63a5\u662f\u5bf9\u8c61\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-java\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@PostMapping(\"\/students\")<\/span>\n<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">public<\/span> String <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">addStudent<\/span><span class=\"hljs-params\">(<span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@RequestParam<\/span> String userName,\n             <span class=\"hljs-meta\" style=\"color: rgb(211, 54, 130);\">@RequestParam<\/span> MultipartFile headerImg)<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">throws<\/span> IOException {\n  <span class=\"hljs-type\" style=\"color: rgb(108, 113, 196);\">String<\/span> <span class=\"hljs-variable\" style=\"color: rgb(220, 50, 47);\">fileName<\/span> <span class=\"hljs-operator\" style=\"color: rgb(147, 161, 161); opacity: 0.7;\">=<\/span> UUID.randomUUID() + <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"_\"<\/span> + headerImg.getOriginalFilename();\n  headerImg.transferTo(<span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">File<\/span>(uploadDir + fileName));\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u5199\u5e93<\/span>\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">return<\/span> <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"redirect:\/student_list\"<\/span>;\n}\n<\/code><\/pre>\n<h3 style=\"font-size: 16px; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 24px; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid rgb(248, 180, 63);\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">3. \u524d\u7aef\uff1aAJAX + FormData \u5f02\u6b65\u4e0a\u4f20\uff08\u5e26\u5934\u50cf\u9884\u89c8\uff09<\/span><\/h3>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u73b0\u4ee3\u540e\u53f0\u51e0\u4e4e\u90fd\u7528\u5f02\u6b65\u63d0\u4ea4\uff0c\u4f53\u9a8c\u66f4\u597d\u2014\u2014\u9009\u5b8c\u56fe\u7acb\u523b\u9884\u89c8\uff0c\u4e0d\u5fc5\u6574\u9875\u5237\u65b0\uff1a<\/p>\n<pre style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; overflow: auto hidden; max-width: 100%; box-sizing: border-box; position: relative; line-height: 1.5; border-radius: 4px; margin: 16px 0px; padding: 0.5em; white-space: pre; word-break: normal; overflow-wrap: normal; background: rgb(0, 43, 54);\"><section style=\"display: block; background-repeat: no-repeat; width: 100%; height: 16px;\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.1\" width=\"45\" height=\"12\" viewBox=\"0 0 450 130\"><ellipse cx=\"65\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(220,60,54)\" stroke-width=\"2\" fill=\"rgb(237,108,96)\"><\/ellipse><ellipse cx=\"225\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(218,151,33)\" stroke-width=\"2\" fill=\"rgb(247,193,81)\"><\/ellipse><ellipse cx=\"385\" cy=\"65\" rx=\"50\" ry=\"52\" stroke=\"rgb(27,161,37)\" stroke-width=\"2\" fill=\"rgb(100,200,86)\"><\/ellipse><\/svg><\/section><code class=\"hljs language-html\" style=\"tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; display: block; overflow: auto hidden; max-width: 100%; box-sizing: border-box; margin: 0.5em; padding: 3px 5px; white-space: nowrap; word-break: normal; overflow-wrap: normal; color: rgb(147, 161, 161); background: rgb(0, 43, 54);\"><span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">form<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"stuForm\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">input<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"text\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"userName\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">placeholder<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u5b66\u751f\u59d3\u540d\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">input<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"file\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"headerImg\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">name<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"headerImg\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">accept<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"image\/*\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">img<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">id<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"preview\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">alt<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"\u5934\u50cf\u9884\u89c8\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">style<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"max-width:120px\"<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">button<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">type<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"button\"<\/span> <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">onclick<\/span>=<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">\"submitForm()\"<\/span>&gt;<\/span>\u6dfb\u52a0<span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">button<\/span>&gt;<\/span>\n<span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">form<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">script<\/span>&gt;<\/span><span class=\"language-javascript\">\n  <span class=\"hljs-comment\" style=\"color: rgb(101, 123, 131);\">\/\/ \u9009\u56fe\u5373\u65f6\u9884\u89c8<\/span>\n  <span class=\"hljs-variable language_\" style=\"color: rgb(220, 50, 47);\">document<\/span>.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">getElementById<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'headerImg'<\/span>).<span class=\"hljs-property\">onchange<\/span> = <span class=\"hljs-function\"><span class=\"hljs-params\">e<\/span> =&gt;<\/span> {\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">const<\/span> url = <span class=\"hljs-variable constant_\" style=\"color: rgb(203, 75, 22);\">URL<\/span>.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">createObjectURL<\/span>(e.<span class=\"hljs-property\">target<\/span>.<span class=\"hljs-property\">files<\/span>[<span class=\"hljs-number\" style=\"color: rgb(203, 75, 22);\">0<\/span>]);\n  <span class=\"hljs-variable language_\" style=\"color: rgb(220, 50, 47);\">document<\/span>.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">getElementById<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'preview'<\/span>).<span class=\"hljs-property\">src<\/span> = url;\n  };\n\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">function<\/span> <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">submitForm<\/span>(<span class=\"hljs-params\"><\/span>) {\n  <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">const<\/span> fd = <span class=\"hljs-keyword\" style=\"color: rgb(108, 113, 196);\">new<\/span> <span class=\"hljs-title class_\" style=\"color: rgb(181, 137, 0);\">FormData<\/span>(<span class=\"hljs-variable language_\" style=\"color: rgb(220, 50, 47);\">document<\/span>.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">getElementById<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'stuForm'<\/span>));\n  <span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">fetch<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'\/students'<\/span>, { <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">method<\/span>: <span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'POST'<\/span>, <span class=\"hljs-attr\" style=\"color: rgb(203, 75, 22);\">body<\/span>: fd })\n    .<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">then<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">r<\/span> =&gt;<\/span> r.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">json<\/span>())\n    .<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">then<\/span>(<span class=\"hljs-function\"><span class=\"hljs-params\">data<\/span> =&gt;<\/span> <span class=\"hljs-variable language_\" style=\"color: rgb(220, 50, 47);\">console<\/span>.<span class=\"hljs-title function_\" style=\"color: rgb(38, 139, 210);\">log<\/span>(<span class=\"hljs-string\" style=\"color: rgb(133, 153, 0);\">'\u4e0a\u4f20\u6210\u529f'<\/span>, data));\n  }\n<\/span><span class=\"hljs-tag\" style=\"color: rgb(131, 148, 150);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(220, 50, 47);\">script<\/span>&gt;<\/span>\n<\/code><\/pre>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4e94\u3001\u5b89\u5168\u4e0e\u907f\u5751\uff08\u52a1\u5fc5\u770b\uff09<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u6587\u4ef6\u4e0a\u4f20\u662f Web \u5b89\u5168\u7684\u91cd\u707e\u533a\uff0c\u4e0a\u7ebf\u524d\u81f3\u5c11\u505a\u8fd9\u51e0\u4ef6\u4e8b\uff1a<\/p>\n<table style=\"display: inline-block !important; width: auto; max-width: 100%; overflow: auto; border-spacing: 0px; border-collapse: collapse; margin: 1rem 0px;\">\n<thead style=\"background: rgb(255, 249, 235); color: rgb(51, 51, 51); text-align: left;\">\n<tr>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u98ce\u9669<\/th>\n<th style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200);\">\u5bf9\u7b56<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u4f20\u4e86\u53ef\u6267\u884c\u811a\u672c<\/strong>\uff08\u5982 <code>.jsp<\/code>\/<code>.php<\/code>\uff09\u88ab\u7ed5\u8fc7\u540e\u95e8<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6269\u5c55\u540d<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u767d\u540d\u5355<\/strong>\u6821\u9a8c\uff0c\u53ea\u5141\u8bb8 <code>jpg\/png\/gif\/webp<\/code> \u7b49<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u8d85\u5927\u6587\u4ef6\u6491\u7206\u78c1\u76d8<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u8bbe <code>fileSizeMax<\/code> \/ Spring \u7684 <code>max-file-size<\/code> \u4e0a\u9650<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u8def\u5f84\u7a7f\u8d8a<\/strong>\uff08<code>filename=\"..\/..\/web.xml\"<\/code>\uff09<\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6587\u4ef6\u540d\u7528 <strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">UUID \u91cd\u547d\u540d<\/strong>\uff0c\u4e22\u5f03\u539f\u59cb\u540d\uff1b\u6216\u7528 <code>FilenameUtils.getName()<\/code> \u53ea\u53d6\u6700\u540e\u4e00\u6bb5<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u91cd\u65b0\u90e8\u7f72\u4e22\u6587\u4ef6<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u4e0d\u8981\u5b58\u5230 <code>webapp\/upload\/<\/code> \u4e0b\uff08\u6253\u5305\u4f1a\u8986\u76d6\uff09\uff0c\u5e94\u5b58\u9879\u76ee\u5916\u76ee\u5f55\u6216<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u5bf9\u8c61\u5b58\u50a8\uff08OSS\/COS\uff09<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\"><strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u56fe\u7247\u5185\u5bb9\u4f2a\u9020<\/strong><\/td>\n<td style=\"font-size: 0.75em; padding: 10px 12px; line-height: 1.6; border: 1px solid rgb(245, 230, 200); min-width: 100px;\">\u6821\u9a8c\u771f\u5b9e <code>Content-Type<\/code> \u6216\u8bfb\u53d6\u6587\u4ef6\u5934\uff08Magic Number\uff09\uff0c\u4e0d\u53ea\u770b\u540e\u7f00<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote style=\"color: rgb(85, 85, 85); background-color: rgb(255, 249, 235); background-image: none; padding: 16px 20px; margin: 20px 0px; border-width: 0px 0px 0px 4px; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(248, 180, 63); border-radius: 6px; font-style: normal; quotes: none;\">\n<p style=\"margin: 0.55em 0px; color: rgb(85, 85, 85); text-indent: 0px; padding: 0px; line-height: 1.75; font-style: normal; background: transparent;\">\u4e00\u53e5\u8bdd\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u6c38\u8fdc\u4e0d\u8981\u628a\u7528\u6237\u4f20\u4e0a\u6765\u7684\u4e1c\u897f\uff0c\u539f\u5c01\u4e0d\u52a8\u5730\u5f53\u6210&#8221;\u53ef\u4fe1\u6587\u4ef6&#8221;\u653e\u5728\u53ef\u88ab\u76f4\u63a5\u8bbf\u95ee\/\u6267\u884c\u7684\u8def\u5f84\u4e0b\u3002<\/strong><\/p>\n<\/blockquote>\n<hr style=\"border-width: 1px medium medium; border-style: solid none none; border-color: rgb(240, 230, 208) currentcolor currentcolor; border-image: none; margin: 24px 0px;\">\n<h2 style=\"display: inline-block; position: relative; font-weight: bold; color: rgb(51, 51, 51); line-height: 1.5; margin-top: 32px; margin-bottom: 16px; padding: 0px 6px 2px; border-width: medium; border-style: none; border-color: currentcolor; border-image: none; text-align: left; background: linear-gradient(to top, rgb(248, 180, 63) 42%, transparent 42%); box-decoration-break: clone; -webkit-box-decoration-break: clone; font-size: 17px;\"><span style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u516d\u3001\u7ed3\u8bed<\/span><\/h2>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">&#8220;\u8868\u5355\u63d0\u4ea4 + \u5934\u50cf\u4e0a\u4f20&#8221;\u770b\u4f3c\u662f\u4e24\u4ef6\u4e8b\uff0c\u5176\u5b9e\u662f\u4e00\u4ef6\u4e8b\uff1a<strong style=\"color: rgb(51, 51, 51); font-weight: bold;\">\u8868\u5355\u63d0\u4ea4\u8d1f\u8d23\u6587\u672c\uff0c\u6587\u4ef6\u4e0a\u4f20\u8d1f\u8d23\u4e8c\u8fdb\u5236\uff0c\u4e8c\u8005\u9760 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">multipart\/form-data<\/code> \u5728\u540c\u4e00\u4e2a\u8bf7\u6c42\u91cc\u88ab\u4e00\u8d77\u6253\u5305<\/strong>\u3002<\/p>\n<ul style=\"margin: 8px 0px; padding-left: 28px; list-style: outside disc;\">\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u60f3\u61c2\u539f\u7406\uff1a\u770b commons-fileupload \u600e\u4e48\u628a\u8bf7\u6c42\u89e3\u6790\u6210 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">FileItem<\/code>\uff1b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u60f3\u5199\u65b0\u9879\u76ee\uff1a\u7528 Servlet 3.0 \u7684 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">Part<\/code> \u6216 Spring \u7684 <code style=\"font-family: Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Roboto Mono&quot;, &quot;Courier New&quot;, &quot;Microsoft YaHei&quot;, monospace; background-color: rgb(255, 244, 230); color: rgb(217, 72, 15); border-radius: 2px; font-size: 14px; padding: 2px 5px; word-break: break-word;\">MultipartFile<\/code>\uff0c\u914d AJAX \u5f02\u6b65\u4e0a\u4f20\uff1b<\/section>\n<\/li>\n<li style=\"margin-bottom: 8px; padding-left: 0px; text-indent: 0px; color: rgb(51, 51, 51); list-style: inherit;\">\n<section>\u60f3\u4e0a\u7ebf\uff1a\u52a1\u5fc5\u8fc7\u4e00\u904d&#8221;\u6269\u5c55\u540d\u767d\u540d\u5355 + \u5927\u5c0f\u9650\u5236 + UUID \u91cd\u547d\u540d + \u5bf9\u8c61\u5b58\u50a8&#8221;\u56db\u9053\u95f8\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-top: 12px; margin-bottom: 12px; color: rgb(51, 51, 51); text-indent: 0px; padding-left: 0px;\">\u628a\u8fd9\u4e00\u5957\u8dd1\u901a\uff0c\u4f60\u5c31\u5177\u5907\u4e86\u540e\u53f0\u7ba1\u7406\u7cfb\u7edf\u91cc\u6700\u5178\u578b\u7684\u4e00\u7c7b&#8221;\u56fe\u6587\u6df7\u5408\u63d0\u4ea4&#8221;\u80fd\u529b\u3002<\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Web \u540e\u53f0\u7ba1\u7406\u7cfb\u7edf\u91cc\uff0c\u6570\u636e\u7684\u589e\u3001\u5220\u3001\u6539\u51e0\u4e4e\u662f\u6807\u914d\uff0c\u672c\u8d28\u90fd\u662f\u5bf9\u6570\u636e\u5e93\u8868\u8bb0\u5f55\u7684\u64cd\u4f5c\u7528\u6237\u754c\u9762\u3002\u5f53\u64cd\u4f5c\u7684\u6570\u636e\u91cc\u5305 [&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\/1819"}],"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=1819"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1819\/revisions"}],"predecessor-version":[{"id":3838,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1819\/revisions\/3838"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}