{"id":51357,"date":"2025-08-10T21:44:21","date_gmt":"2025-08-10T13:44:21","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51357.html"},"modified":"2025-08-10T21:44:21","modified_gmt":"2025-08-10T13:44:21","slug":"springboot%e5%ae%9e%e7%8e%b0%e6%96%87%e4%bb%b6%e4%b8%8a%e4%bc%a0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51357.html","title":{"rendered":"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20"},"content":{"rendered":"<h3 id=\"apTy-1754831543710\">1\u3001yml\u8bbe\u7f6e<\/h3>\n<h4 id=\"HhT2-1754831543712\">1.\u5bf9\u4e8e\u6587\u4ef6\u8fdb\u884c\u8bbe\u7f6e<\/h4>\n<p>spring:<br \/>\n  servlet:<br \/>\n    multipart:<br \/>\n      # \u8bbe\u7f6e\u6587\u4ef6\u6700\u5927\u5927\u5c0f<br \/>\n      max-file-size: 100MB<br \/>\n      # \u8bbe\u7f6e\u8bf7\u6c42\u6700\u5927\u5927\u5c0f<br \/>\n      max-request-size: 100MB<\/p>\n<h4 id=\"R7vG-1754831559380\">2.\u8bbe\u7f6e\u6587\u4ef6\u5b58\u50a8\u8def\u5f84<\/h4>\n<p>\u8fd9\u91cc\u4f7f\u7528\u672c\u5730\u6587\u4ef6\u8def\u5f84\u6a21\u62df\u6587\u4ef6\u670d\u52a1\u5668<\/p>\n<p># \u6587\u4ef6\u4e0a\u4f20\u4f4d\u7f6e<br \/>\nupload-path:<br \/>\n  url: http:\/\/localhost:8080\/<br \/>\n  face: D:\/community\/upload\/face\/<br \/>\n  file: D:\/community\/upload\/file\/<\/p>\n<h5 id=\"aUMr-1754831570990\">&#xff08;1&#xff09;\u00a0upload-path<\/h5>\n<p>\u81ea\u5b9a\u4e49\u914d\u7f6e\u524d\u7f00&#xff08;\u4e0d\u662f Spring Boot \u81ea\u5e26\u7684&#xff09;&#xff0c;\u901a\u8fc7\u00a0&#064;ConfigurationProperties\u00a0\u6216\u00a0&#064;Value\u00a0\u6ce8\u89e3\u6ce8\u5165\u5230 Java \u7c7b\u4e2d\u3002<\/p>\n<h5 id=\"dItN-1754831570994\">&#xff08;2&#xff09;\u00a0url: http:\/\/localhost:8080\/<\/h5>\n<ul style=\"margin-left:0;margin-right:0\">\n<li style=\"text-align:left\">\u8868\u793a\u6587\u4ef6\u4e0a\u4f20\u540e&#xff0c;\u5bf9\u5916\u8bbf\u95ee\u7684\u57fa\u7840 URL\u3002<\/li>\n<li style=\"text-align:left\">\u4f8b\u5982&#xff0c;\u4fdd\u5b58\u7684\u6587\u4ef6\u672c\u5730\u8def\u5f84\u662f\u00a0D:\/community\/upload\/face\/abc.jpg&#xff0c;\u8bbf\u95ee URL \u5c31\u53ef\u4ee5\u662f&#xff1a;<\/li>\n<\/ul>\n<p>http:\/\/localhost:8080\/face\/abc.jpg<\/p>\n<ul style=\"margin-left:0;margin-right:0\">\n<li style=\"text-align:left\">\u6ce8\u610f&#xff1a;\u8981\u80fd\u8bbf\u95ee\u8fd9\u4e2a URL&#xff0c;\u9700\u8981\u5728\u00a0WebMvcConfigurer\u00a0\u4e2d\u914d\u7f6e\u9759\u6001\u8d44\u6e90\u6620\u5c04&#xff0c;\u628a\u00a0D:\/community\/upload\/face\/\u00a0\u66b4\u9732\u6210\u00a0\/face\/\u00a0\u8def\u5f84\u3002<\/li>\n<\/ul>\n<h5 id=\"n6HP-1754831741707\">&#xff08;3&#xff09;\u00a0face: D:\/community\/upload\/face\/<\/h5>\n<ul style=\"margin-left:0;margin-right:0\">\n<li style=\"text-align:left\">\u4e13\u95e8\u5b58\u50a8\u4eba\u8138\u56fe\u7247\u7684\u672c\u5730\u78c1\u76d8\u76ee\u5f55\u3002<\/li>\n<li style=\"text-align:left\">\u5f53\u4e0a\u4f20\u4eba\u8138\u56fe\u7247\u65f6&#xff0c;\u9879\u76ee\u4f1a\u628a\u6587\u4ef6\u4fdd\u5b58\u5230\u8fd9\u4e2a\u76ee\u5f55\u3002<\/li>\n<li style=\"text-align:left\">\u6bd4\u5982&#xff1a;\n<ul>\n<li style=\"text-align:left\">\u4e0a\u4f20\u4e00\u5f20jpg<\/li>\n<li style=\"text-align:left\">\u4fdd\u5b58\u5230D:\/community\/upload\/face\/test.jpg<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5 id=\"WlKh-1754831822158\">&#xff08;4&#xff09;\u00a0file: D:\/community\/upload\/file\/<\/h5>\n<ul style=\"margin-left:0;margin-right:0\">\n<li style=\"text-align:left\">\u4e13\u95e8\u5b58\u50a8\u5176\u4ed6\u7c7b\u578b\u6587\u4ef6&#xff08;\u975e\u4eba\u8138\u56fe\u7247&#xff0c;\u6bd4\u5982\u6587\u6863\u3001\u538b\u7f29\u5305\u7b49&#xff09;\u7684\u672c\u5730\u78c1\u76d8\u76ee\u5f55\u3002<\/li>\n<li style=\"text-align:left\">\u7528\u6cd5\u548c\u00a0face\u00a0\u7c7b\u4f3c&#xff0c;\u53ea\u662f\u5206\u4e86\u4e0d\u540c\u6587\u4ef6\u5939\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<h3 id=\"x4Ly-1754831832237\">2\u3001\u914d\u7f6e\u62e6\u622a\u5668&#xff0c;\u5c06file\u7684\u8bf7\u6c42\u62e6\u622a<\/h3>\n<p>package com.qcby.config;<\/p>\n<p>import org.springframework.beans.factory.annotation.Autowired;<br \/>\nimport org.springframework.beans.factory.annotation.Value;<br \/>\nimport org.springframework.context.annotation.Configuration;<br \/>\nimport org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;<br \/>\nimport org.springframework.web.servlet.config.annotation.WebMvcConfigurer;<\/p>\n<p>&#064;Configuration<br \/>\npublic class WebMVCConfiguration implements WebMvcConfigurer {<br \/>\n    &#064;Value(&#034;${upload-path.face}&#034;)<br \/>\n    private String face;<br \/>\n    &#064;Value(&#034;${upload-path.file}&#034;)<br \/>\n    private String file;<br \/>\n    &#064;Override<br \/>\n    public void addResourceHandlers(ResourceHandlerRegistry registry) {<br \/>\n        registry.addResourceHandler(&#034;\/community\/upload\/face\/**&#034;)<br \/>\n                .addResourceLocations(&#034;file:&#034;&#043;face);<br \/>\n        registry.addResourceHandler(&#034;\/community\/upload\/file\/**&#034;)<br \/>\n                .addResourceLocations(&#034;file:&#034;&#043;file);<br \/>\n    }<br \/>\n}<\/p>\n<p>\u5c06 URL \u8bf7\u6c42\u8def\u5f84&#xff08;\/community\/upload\/face\/**&#xff09;\u548c\u78c1\u76d8\u8def\u5f84&#xff08;D:\/community\/upload\/face\/&#xff09;\u7ed1\u5b9a&#xff0c;\u8ba9\u6d4f\u89c8\u5668\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u78c1\u76d8\u4e0a\u7684\u6587\u4ef6\u3002<\/p>\n<p>\u5f53\u7528\u6237\u8bbf\u95ee\u00a0http:\/\/localhost:8080\/community\/upload\/face\/abc.jpg<\/p>\n<p>Spring Boot \u4f1a\u53bb\u00a0D:\/community\/upload\/face\/abc.jpg\u00a0\u627e\u8fd9\u4e2a\u6587\u4ef6&#xff0c;\u5e76\u76f4\u63a5\u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668<\/p>\n<p>\u524d\u7aef\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/123.jpg\u65f6&#xff0c;Springboot\u4f1a\u6620\u5c04\u5230file:D:\/community\/upload\/face\/123.jpg&#xff0c;\u534f\u8bae\u7684\u5207\u6362\u548clocalhost:8080\u7684\u53d8\u52a8\u662f\u5982\u4f55\u5b9e\u73b0\u7684<\/p>\n<h5 id=\"UBbu-1754831857616\">\u2460Spring MVC \u7684\u8d44\u6e90\u5904\u7406\u673a\u5236<\/h5>\n<p>\u8fd9\u662fSpring MVC \u63d0\u4f9b\u7684\u00a0\u9759\u6001\u8d44\u6e90\u5904\u7406\u673a\u5236\u00a0\u5728\u5de5\u4f5c<\/p>\n<p>Spring Boot&#xff08;\u5e95\u5c42\u662f Spring MVC&#xff09;\u5728\u542f\u52a8\u65f6&#xff0c;\u4f1a\u626b\u63cf\u914d\u7f6e\u7684\u9759\u6001\u8d44\u6e90\u5904\u7406\u5668&#xff08;ResourceHttpRequestHandler)&#xff0c;\u8fd9\u4e2a\u5904\u7406\u5668\u6709\u4e24\u4e2a\u5173\u952e\u70b9&#xff1a;<\/p>\n<h6 id=\"BnW5-1754831857622\">1. \u5339\u914d URL \u8def\u5f84\u6a21\u5f0f&#xff08;\/community\/upload\/face\/**&#xff09;<\/h6>\n<p>\u5f53\u6d4f\u89c8\u5668\u8bbf\u95ee\u7684 URL\u00a0\u8def\u5f84\u90e8\u5206&#xff08;\u4e0d\u5305\u62ec\u534f\u8bae\u3001\u57df\u540d\u3001\u7aef\u53e3&#xff09;\u7b26\u5408\u8fd9\u4e2a\u6a21\u5f0f\u65f6&#xff0c;\u8fd9\u4e2a\u5904\u7406\u5668\u4f1a\u63a5\u7ba1\u8bf7\u6c42\u3002<\/p>\n<p>http:\/\/localhost:8080\/community\/upload\/face\/123.jpg\u00a0\u2192 \u5339\u914d\u8def\u5f84\u00a0\/community\/upload\/face\/123.jpg\u3002<\/p>\n<h6 id=\"EOMG-1754831857628\">2. \u6620\u5c04\u5230\u7269\u7406\u8d44\u6e90\u4f4d\u7f6e&#xff08;file:D:\/community\/upload\/face\/&#xff09;<\/h6>\n<p>file:\u00a0\u534f\u8bae\u544a\u8bc9 Spring MVC&#xff1a;\u8d44\u6e90\u5728\u672c\u5730\u6587\u4ef6\u7cfb\u7edf&#xff0c;\u4e0d\u662f\u5728 classpath \u91cc\u3002<\/p>\n<p>\u628a URL \u8def\u5f84\u4e2d\u7684\u5339\u914d\u90e8\u5206\u53bb\u6389&#xff0c;\u62fc\u5230\u7269\u7406\u8def\u5f84\u540e\u9762&#xff1a;<\/p>\n<p>D:\/community\/upload\/face\/ &#043; 123.jpg<\/p>\n<p>\u7136\u540e\u8bfb\u53d6\u6587\u4ef6\u5e76\u901a\u8fc7 HTTP \u54cd\u5e94\u6d41\u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668\u3002<\/p>\n<h5 id=\"odGa-1754831857638\">\u2461\u201clocalhost:8080\u201d \u6ca1\u6709\u88ab\u6362\u6210\u6587\u4ef6\u8def\u5f84<\/h5>\n<p>\u5f88\u591a\u4eba\u4f1a\u4ee5\u4e3a\u00a0localhost:8080\u00a0\u88ab\u66ff\u6362\u6210\u00a0file:\u00a0\u8def\u5f84&#xff0c;\u5176\u5b9e\u4e0d\u662f\u3002<\/p>\n<p>\u5b9e\u9645\u8fc7\u7a0b\u662f\u8fd9\u6837\u7684&#xff1a;<\/p>\n<p style=\"text-align:left\">1. \u6d4f\u89c8\u5668\u8bf7\u6c42<\/p>\n<p>GET http:\/\/localhost:8080\/community\/upload\/face\/123.jpg<\/p>\n<p>2. Tomcat \u63a5\u6536\u8bf7\u6c42<\/p>\n<p>Spring Boot \u5185\u7f6e Tomcat \u76d1\u542c\u00a08080\u00a0\u7aef\u53e3&#xff0c;\u63a5\u6536\u5230\u00a0\/community\/upload\/face\/123.jpg\u00a0\u8fd9\u4e2a\u8def\u5f84\u7684\u8bf7\u6c42\u3002<\/p>\n<p>3.Spring MVC \u5339\u914d\u5904\u7406\u5668<\/p>\n<p>\u5b83\u53d1\u73b0\u00a0\/community\/upload\/face\/**\u00a0\u7684\u89c4\u5219\u88ab\u547d\u4e2d&#xff0c;\u5c31\u4ea4\u7ed9\u00a0ResourceHttpRequestHandler\u3002<\/p>\n<p>4.\u5904\u7406\u5668\u8bfb\u53d6\u672c\u5730\u6587\u4ef6<\/p>\n<p>\u6839\u636e\u00a0file:D:\/community\/upload\/face\/\u00a0\u8fd9\u4e2a\u914d\u7f6e&#xff0c;\u628a URL \u91cc\u5269\u4e0b\u7684\u90e8\u5206\u00a0123.jpg\u00a0\u62fc\u5230\u8def\u5f84\u672b\u5c3e&#xff0c;\u5f97\u5230&#xff1a;<\/p>\n<p>D:\/community\/upload\/face\/123.jpg<\/p>\n<p>\u6253\u5f00\u6587\u4ef6&#xff0c;\u628a\u4e8c\u8fdb\u5236\u5185\u5bb9\u5199\u5230 HTTP \u54cd\u5e94\u4e2d\u3002<\/p>\n<p>5.\u6d4f\u89c8\u5668\u663e\u793a\u56fe\u7247<\/p>\n<p>\u5bf9\u6d4f\u89c8\u5668\u6765\u8bf4&#xff0c;\u5b83\u4ecd\u7136\u662f\u6536\u5230\u4e86\u00a0http:\/\/localhost:8080\/&#8230;\u00a0\u7684\u54cd\u5e94&#xff0c;\u53ea\u4e0d\u8fc7\u5185\u5bb9\u662f JPG \u56fe\u7247\u3002<\/p>\n<h5 id=\"PXbz-1754832008340\">\u2462\u534f\u8bae\u548c\u7aef\u53e3\u6ca1\u6709\u53d8\u5316<\/h5>\n<p>\u6d4f\u89c8\u5668\u770b\u5230\u7684\u59cb\u7ec8\u662f\u00a0http:\/\/localhost:8080\/&#8230;&#xff0c;HTTP \u534f\u8bae\u548c\u7aef\u53e3\u00a08080\u00a0\u6ca1\u53d8\u3002<\/p>\n<p>\u53ea\u662f\u5728\u670d\u52a1\u7aef\u5185\u90e8&#xff0c;Spring MVC \u628a\u8fd9\u4e2a HTTP \u8bf7\u6c42\u6620\u5c04\u5230\u4e86\u672c\u5730\u6587\u4ef6\u7cfb\u7edf&#xff0c;\u5e76\u8bfb\u53d6\u4e86\u6587\u4ef6\u5185\u5bb9\u4f5c\u4e3a HTTP \u54cd\u5e94\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4&#xff1a;<\/p>\n<p>\u5bf9\u5ba2\u6237\u7aef \u2192 \u5b83\u662f\u5728\u8bbf\u95ee HTTP URL<\/p>\n<p>\u5bf9\u670d\u52a1\u7aef \u2192 \u5b83\u662f\u5728\u8bfb\u786c\u76d8\u6587\u4ef6\u5e76\u901a\u8fc7 HTTP \u8fd4\u56de<\/p>\n<h3 id=\"AcNu-1754832012863\">3\u3001\u4eba\u8138\u56fe\u7247\u8bc6\u522b\u5e76\u4e0a\u4f20<\/h3>\n<p>&#064;Autowired<br \/>\nprivate ICommunityService communityService;<br \/>\n&#064;Autowired<br \/>\nprivate IPersonService personService;<br \/>\n&#064;Value(&#034;${upload-path.url}&#034;)<br \/>\nprivate String uploadUrlPath;<br \/>\n&#064;Value(&#034;${upload-path.face}&#034;)<br \/>\nprivate String faceLocalPath;<br \/>\n&#064;Autowired<br \/>\nprivate ApiConfiguration apiConfiguration;<br \/>\n\/**<br \/>\n * \u5f55\u5165\u5c45\u6c11\u4eba\u8138\u4fe1\u606f<br \/>\n * &#064;return<br \/>\n *\/<br \/>\n&#064;PostMapping(&#034;\/addPerson&#034;)<br \/>\npublic Result addPersonImg(&#064;RequestBody FaceForm faceForm){<br \/>\n    System.out.println(&#034;\u8fdb\u5165\u5230addPerson&#034;);<br \/>\n    System.out.println(faceForm.getExtName());<br \/>\n    Person person &#061; personService.getById(faceForm.getPersonId());<br \/>\n    \/\/ \u4e25\u8c28\u6027\u5224\u65ad&#xff0c;\u53c2\u6570\u662f\u5426\u4e3a\u7a7a<br \/>\n    if(faceForm.getFileBase64()&#061;&#061; null || faceForm.getFileBase64().equals(&#034;&#034;)){<br \/>\n        return Result.error(&#034;\u8bf7\u4e0a\u4f20\u4eba\u8138\u56fe\u7247&#034;);<br \/>\n    }<br \/>\n    \/\/ \u5224\u65ad\u662f\u5426\u662f\u4eba\u8138&#xff0c;\u5982\u679c\u4e0d\u662f&#xff0c;\u76f4\u63a5\u8fd4\u56de<br \/>\n    if(apiConfiguration.isUsed()){<br \/>\n        String faceId &#061; newPerson(faceForm,person.getUserName());<br \/>\n        if(faceId &#061;&#061; null){<br \/>\n            return Result.error(&#034;\u4eba\u8138\u8bc6\u522b\u5931\u8d25&#034;);<br \/>\n        }else{<br \/>\n            String fileName &#061; faceId &#043; &#034;.&#034; &#043; faceForm.getExtName();<br \/>\n            String faceUrl &#061; uploadUrlPath &#043; faceLocalPath.substring(3) &#043; fileName;<br \/>\n            person.setFaceUrl(faceUrl);<br \/>\n            person.setState(2);<br \/>\n            personService.updateById(person);<br \/>\n            return Result.ok();<br \/>\n        }<br \/>\n    }else{<br \/>\n        return Result.error(&#034;\u4eba\u8138\u8bc6\u522b\u5f00\u542f\u5931\u8d25&#034;);<br \/>\n    }<br \/>\n}<\/p>\n<p>\/**<br \/>\n * \u521b\u5efa\u4eba\u8138\u4fe1\u606f&#xff0c;\u8c03\u7528\u4eba\u8138\u8bc6\u522bAPI&#xff0c;\u8fdb\u884c\u4eba\u8138\u6bd4\u5bf9<br \/>\n * &#064;param faceForm<br \/>\n * &#064;param userName<br \/>\n * &#064;return<br \/>\n *\/<br \/>\nprivate String newPerson(FaceForm faceForm, String userName) {<br \/>\n    String faceId &#061; null;<br \/>\n    String fileBase64 &#061; faceForm.getFileBase64();<br \/>\n    String extName &#061; faceForm.getExtName();<br \/>\n    String personId &#061; faceForm.getPersonId()&#043;&#034;&#034;;<br \/>\n    String savePath &#061; faceLocalPath;<br \/>\n    if(fileBase64 !&#061; null &amp;&amp; !fileBase64.equals(&#034;&#034;)){<br \/>\n        FaceApi faceApi &#061; new FaceApi();<br \/>\n        RootResp newperson &#061; faceApi.newperson(apiConfiguration, personId, userName, fileBase64);<br \/>\n        if(newperson.getRet()&#061;&#061;0){<br \/>\n            JSONObject jsonObject &#061; JSON.parseObject(newperson.getData().toString());<br \/>\n            faceId &#061; jsonObject.getString(&#034;FaceId&#034;);<br \/>\n            if(faceId!&#061;null){<br \/>\n                savePath &#061; savePath &#043; faceId &#043; &#034;.&#034;&#043;extName;<br \/>\n                try {<br \/>\n                    Base64Util.decoderBase64File(fileBase64,savePath);<br \/>\n                } catch (Exception e) {<br \/>\n                    e.printStackTrace();<br \/>\n                }<br \/>\n            }<br \/>\n        } else{<br \/>\n            return faceId;<br \/>\n        }<br \/>\n    }<br \/>\n    return faceId;<br \/>\n}<\/p>\n<h4 id=\"5VKV-1754832030611\">1.\u914d\u7f6e\u5982\u4f55\u53c2\u4e0e<\/h4>\n<p>&#064;Value(&#034;${upload-path.url}&#034;) private String uploadUrlPath;\u6765\u81ea yml \u7684\u201c\u5bf9\u5916\u57fa\u7840 URL\u201d&#xff0c;\u4f8b\u5982\u00a0http:\/\/localhost:8080\/\u3002<\/p>\n<p>&#064;Value(&#034;${upload-path.face}&#034;) private String faceLocalPath;\u6765\u81ea yml \u7684\u201c\u4eba\u8138\u56fe\u7247\u672c\u5730\u76ee\u5f55\u201d&#xff0c;\u4f8b\u5982\u00a0D:\/community\/upload\/face\/\u3002<\/p>\n<p>\u540c\u65f6\u4f60\u5728\u00a0WebMVCConfiguration\u00a0\u91cc\u628a&#xff1a;<\/p>\n<p>&#034;\/community\/upload\/face\/**&#034; \u2194 &#034;file:D:\/community\/upload\/face\/&#034;<\/p>\n<p>\u505a\u4e86\u9759\u6001\u8d44\u6e90\u6620\u5c04\u3002\u8fd9\u610f\u5473\u7740\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/xxx.jpg \u65f6&#xff0c;Spring \u4f1a\u4ece\u00a0D:\/community\/upload\/face\/xxx.jpg\u00a0\u8bfb\u6587\u4ef6\u5e76\u8fd4\u56de\u3002<\/p>\n<h4 id=\"WsMy-1754832044709\">\u4ee3\u7801\u6574\u4f53\u6d41\u7a0b&#xff08;\u63a7\u5236\u5c42 &#043; \u843d\u76d8&#xff09;<\/h4>\n<li style=\"text-align:left\">\u63a5\u6536\u8bf7\u6c42&#xff08;\/addPerson&#xff09;\u53d6\u5230\u00a0FaceForm&#xff08;\u91cc\u6709\u00a0fileBase64,\u00a0extName,\u00a0personId&#xff09;\u3002<\/li>\n<li style=\"text-align:left\">\u6821\u9a8c\u00a0<span style=\"background-color:null\">fileBase64<\/span>\u00a0\u4e3a\u7a7a\u5c31\u76f4\u63a5\u62a5\u9519\u8fd4\u56de\u3002<\/li>\n<li style=\"text-align:left\">\u5f00\u5173\u68c0\u6d4bapiConfiguration.isUsed()\u00a0\u63a7\u5236\u662f\u5426\u542f\u7528\u4eba\u8138\u8bc6\u522b\u3002<\/li>\n<li style=\"text-align:left\">\u8c03\u7528\u8bc6\u522b\u5e76\u4fdd\u5b58\u6587\u4ef6&#xff08;newPerson()&#xff09;\n<li style=\"text-align:left\">\n<p>\u628a Base64 \u53d1\u7ed9\u7b2c\u4e09\u65b9\u4eba\u8138 API&#xff08;faceApi.newperson(&#8230;)&#xff09;<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u6210\u529f\u8fd4\u56de\u540e\u4ece\u54cd\u5e94\u91cc\u62ff\u5230\u00a0FaceId<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u7528\u00a0FaceId &#043; &#034;.&#034; &#043; extName\u00a0\u4f5c\u4e3a\u6587\u4ef6\u540d&#xff0c;\u62fc\u6210&#xff1a;savePath &#061; faceLocalPath &#043; faceId &#043; &#034;.&#034; &#043; extName\u6bd4\u5982&#xff1a;D:\/community\/upload\/face\/ab12cd34.jpg<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u7528\u00a0Base64Util.decoderBase64File(fileBase64, savePath)\u00a0\u628a Base64 \u89e3\u7801\u5199\u5165\u78c1\u76d8<\/p>\n<\/li>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u751f\u6210\u53ef\u8bbf\u95ee URL &#043; \u66f4\u65b0\u5e93<\/p>\n<li style=\"text-align:left\">\n<p>\u6784\u9020\u00a0fileName &#061; faceId &#043; &#034;.&#034; &#043; extName<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u7ec4\u88c5\u00a0faceUrl&#xff0c;\u7136\u540e\u00a0person.setFaceUrl(faceUrl)&#xff0c;\u5e76\u00a0updateById<\/p>\n<\/li>\n<\/li>\n<h3 id=\"pVkp-1754832125959\">4\u3001EXCEL\u8868\u7684\u5bfc\u5165\u548c\u5bfc\u51fa<\/h3>\n<p>\/**<br \/>\n     * \u6570\u636e\u7684\u5bfc\u51fa\u529f\u80fd\u5b9e\u73b0<br \/>\n     * &#064;param personListForm<br \/>\n     * &#064;return<br \/>\n     *\/<br \/>\n    &#064;GetMapping(&#034;\/exportExcel&#034;)<br \/>\n    public Result exportExcel(PersonListForm personListForm){<br \/>\n       \/\/1.\u83b7\u53d6\u6ee1\u8db3\u6761\u4ef6\u7684\u6570\u636e<br \/>\n        PageVO pageVO &#061; personService.personList(personListForm);<br \/>\n       \/\/2.\u53ea\u9700\u8981\u6ee1\u8db3\u6761\u4ef6\u7684\u6570\u636e\u5373\u53ef<br \/>\n        List list &#061; pageVO.getList();<br \/>\n       \/\/3.\u5904\u7406\u6570\u636e\u653e\u5165\u5230EXcel\u8868\u683c\u5f53\u4e2d<br \/>\n        String path &#061; excel;<br \/>\n        path&#061;ExcelUtil.ExpPersonInfo(list, path);<br \/>\n        return Result.ok().put(&#034;data&#034;, path);<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u6587\u4ef6\u4e0a\u4f20<br \/>\n     * &#064;param file<br \/>\n     * &#064;return<br \/>\n     * &#064;throws Exception<br \/>\n     *\/<br \/>\n    &#064;PostMapping(&#034;\/excelUpload&#034;)<br \/>\n    public Result excelUpload(&#064;RequestParam(&#034;uploadExcel&#034;) MultipartFile file) throws Exception {<br \/>\n        if(file.getOriginalFilename().equals(&#034;&#034;)){<br \/>\n            return Result.error(&#034;\u6ca1\u6709\u9009\u4e2d\u8981\u4e0a\u4f20\u7684\u6587\u4ef6&#034;);<br \/>\n        }else {<br \/>\n            String picName &#061; UUID.randomUUID().toString();<br \/>\n            String oriName &#061; file.getOriginalFilename();<br \/>\n            String extName &#061; oriName.substring(oriName.lastIndexOf(&#034;.&#034;));<br \/>\n            String newFileName &#061; picName &#043; extName;<br \/>\n            File targetFile &#061; new File(excel, newFileName);<br \/>\n            \/\/ \u4fdd\u5b58\u6587\u4ef6<br \/>\n            file.transferTo(targetFile);<br \/>\n            return Result.ok().put(&#034;data&#034;,newFileName);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u5b9e\u73b0\u6570\u636e\u5e93\u65b0\u589e\u8868\u4e2d\u6570\u636e<br \/>\n     * \u6570\u636e\u5bfc\u5165\u64cd\u4f5c<br \/>\n     * &#064;param fileName<br \/>\n     * &#064;param session<br \/>\n     * &#064;return<br \/>\n     *\/<br \/>\n    &#064;PostMapping(&#034;\/parsefile\/{fileName}&#034;)<br \/>\n    public Result parsefile(&#064;PathVariable(&#034;fileName&#034;) String fileName,HttpSession session){<br \/>\n        User user &#061; (User) session.getAttribute(&#034;user&#034;);<br \/>\n        \/\/POIFSFileSystem \u662f Apache POI \u5e93\u4e2d\u7684\u6838\u5fc3\u7c7b<br \/>\n        \/\/\u4e13\u95e8\u7528\u4e8e\u5904\u7406 OLE 2 Compound Document Format&#xff08;\u5fae\u8f6f\u590d\u5408\u6587\u6863\u683c\u5f0f&#xff09;<br \/>\n        \/\/\u662f Java \u5f00\u53d1\u4e2d\u5904\u7406\u4f20\u7edf Microsoft Office \u6587\u6863&#xff08;\u5982 .xls, .doc, .ppt&#xff09;\u7684\u57fa\u7840\u7ec4\u4ef6<br \/>\n        POIFSFileSystem fs &#061; null;<br \/>\n        \/\/HSSFWorkbook \u662f Apache POI \u5e93\u4e2d\u5904\u7406 Microsoft Excel \u683c\u5f0f&#xff08;.xls \u6587\u4ef6&#xff09;\u7684\u6838\u5fc3\u7c7b<br \/>\n        \/\/ \u4f5c\u4e3a Horrible SpreadSheet Format \u7684\u7f29\u5199&#xff0c;\u5b83\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684 API \u6765\u521b\u5efa\u3001\u8bfb\u53d6\u548c\u4fee\u6539\u4f20\u7edf Excel<br \/>\n        \/\/ \u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<br \/>\n        HSSFWorkbook wb &#061; null;<br \/>\n        try {<br \/>\n            String basePath &#061; excel &#043; fileName;<br \/>\n            fs &#061; new POIFSFileSystem(new FileInputStream(basePath));<br \/>\n            wb &#061; new HSSFWorkbook(fs);<br \/>\n        } catch (Exception e) {<br \/>\n            e.printStackTrace();<br \/>\n        }<br \/>\n        \/\/\u8fd9\u6bb5\u4ee3\u7801\u7684\u6838\u5fc3\u529f\u80fd\u662f\u4eceExcel\u4e2d\u63d0\u53d6\u6570\u636e\u5230\u4e8c\u7ef4\u6570\u7ec4&#xff0c;\u7279\u522b\u5904\u7406\u4e86\u7b2c\u4e00\u5217\u7684\u6570\u503c\u8f6c\u6362\u3002<br \/>\n        HSSFSheet sheet &#061; wb.getSheetAt(0);\/\/ \u83b7\u53d6\u5de5\u4f5c\u7c3f\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5de5\u4f5c\u8868<br \/>\n        Object[][] data &#061; null;\/\/ \u58f0\u660e\u4e8c\u7ef4\u6570\u7ec4\u7528\u4e8e\u5b58\u50a8\u6570\u636e<br \/>\n        int r &#061; sheet.getLastRowNum()&#043;1;\/\/ \u83b7\u53d6\u603b\u884c\u6570&#xff08;\u7d22\u5f15\u4ece0\u5f00\u59cb&#xff09;<br \/>\n        int c &#061; sheet.getRow(0).getLastCellNum();\/\/ \u83b7\u53d6\u7b2c\u4e00\u884c\u7684\u5217\u6570<br \/>\n        int headRow &#061; 2;\/\/ \u8868\u5934\u884c\u6570&#xff08;\u8df3\u8fc7\u524d2\u884c&#xff09;<br \/>\n        data &#061; new Object[r &#8211; headRow][c];\/\/ \u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4&#xff08;\u884c\u6570&#061;\u603b\u884c\u6570-\u8868\u5934\u884c&#xff09;<br \/>\n        for (int i &#061; headRow; i &lt; r; i&#043;&#043;) {\/\/ \u4ece\u7b2c3\u884c\u5f00\u59cb&#xff08;\u8df3\u8fc7\u8868\u5934&#xff09;<br \/>\n            HSSFRow row &#061; sheet.getRow(i); \/\/ \u83b7\u53d6\u5f53\u524d\u884c<br \/>\n            for (int j &#061; 0; j &lt; c; j&#043;&#043;) {\/\/ \u904d\u5386\u6bcf\u5217<br \/>\n                HSSFCell cell &#061; null;<br \/>\n                try {<br \/>\n                    cell &#061; row.getCell(j); \/\/ \u83b7\u53d6\u5355\u5143\u683c<br \/>\n                    try {<br \/>\n                        cell &#061; row.getCell(j);<br \/>\n                        DataFormatter dataFormater &#061; new DataFormatter();\/\/\u4f7f\u7528DataFormatter\u5c06\u5355\u5143\u683c\u503c\u7edf\u4e00\u8f6c\u4e3a\u5b57\u7b26\u4e32<br \/>\n                        String a &#061; dataFormater.formatCellValue(cell); \/\/ \u683c\u5f0f\u5316\u5355\u5143\u683c\u503c\u4e3a\u5b57\u7b26\u4e32<br \/>\n                        data[i &#8211; headRow][j] &#061; a;\/\/ \u5b58\u50a8\u5230\u6570\u7ec4<br \/>\n                    } catch (Exception e) {<br \/>\n                        \/\/ \u5f02\u5e38\u5904\u7406&#xff1a;\u5f53\u5355\u5143\u683c\u8bfb\u53d6\u5931\u8d25\u65f6<br \/>\n                        data[i-headRow][j] &#061; &#034;&#034;; \/\/ \u5148\u8bbe\u7f6e\u4e3a\u7a7a\u5b57\u7b26\u4e32<br \/>\n                        \/\/ \u7279\u6b8a\u5904\u7406\u7b2c\u4e00\u5217&#xff08;\u7d22\u5f150&#xff09;<br \/>\n                        if(j&#061;&#061;0){<br \/>\n                            try {<br \/>\n                                double d &#061; cell.getNumericCellValue();\/\/ \u5c1d\u8bd5\u83b7\u53d6\u6570\u503c<br \/>\n                                data[i &#8211; headRow][j] &#061; (int)d &#043; &#034;&#034;;\/\/ \u8f6c\u6362\u4e3a\u6574\u6570\u540e\u5b58\u50a8\u4e3a\u5b57\u7b26\u4e32<br \/>\n                            }catch(Exception ex){<br \/>\n                                data[i-headRow][j] &#061; &#034;&#034;;\/\/ \u5982\u679c\u8f6c\u6362\u5931\u8d25&#xff0c;\u4fdd\u6301\u4e3a\u7a7a<br \/>\n                            }<br \/>\n                        }<br \/>\n                    }<br \/>\n                } catch (Exception e) {<br \/>\n                    System.out.println(&#034;i&#061;&#034;&#043;i&#043;&#034;;j&#061;&#034;&#043;j&#043;&#034;:&#034;&#043;e.getMessage());<br \/>\n                }<br \/>\n            }<br \/>\n        }<\/p>\n<p>        int row &#061; data.length;<br \/>\n        int col &#061; 0;<br \/>\n        String errinfo &#061; &#034;&#034;;<br \/>\n        headRow &#061; 3;<br \/>\n        \/\/String[] stitle&#061;{&#034;ID&#034;,&#034;\u5c0f\u533a\u540d\u79f0&#034;,&#034;\u6240\u5c5e\u697c\u680b&#034;,&#034;\u623f\u53f7&#034;,&#034;\u59d3\u540d&#034;,&#034;\u6027\u522b&#034;,&#034;\u624b\u673a\u53f7\u7801&#034;,&#034;\u5c45\u4f4f\u6027\u8d28&#034;,&#034;\u72b6\u6001&#034;,&#034;\u5907\u6ce8&#034;};<br \/>\n        errinfo &#061; &#034;&#034;;<br \/>\n        for (int i &#061; 0; i &lt; row; i&#043;&#043;) {<br \/>\n            Person single &#061; new Person();<br \/>\n            single.setPersonId(0);<br \/>\n            single.setState(1);<br \/>\n            single.setFaceUrl(&#034;&#034;);<br \/>\n            try {<br \/>\n                col&#061;1;<br \/>\n                String communityName &#061; data[i][col&#043;&#043;].toString();<br \/>\n                QueryWrapper&lt;Community&gt; queryWrapper &#061; new QueryWrapper&lt;&gt;();<br \/>\n                queryWrapper.eq(&#034;community_name&#034;, communityName);<br \/>\n                Community community &#061; this.communityService.getOne(queryWrapper);<br \/>\n                if( community &#061;&#061; null){<br \/>\n                    errinfo &#043;&#061; &#034;Excel\u6587\u4ef6\u7b2c&#034; &#043; (i &#043; headRow) &#043; &#034;\u884c\u5c0f\u533a\u540d\u79f0\u4e0d\u5b58\u5728&#xff01;&#034;;<br \/>\n                    return Result.ok().put(&#034;status&#034;, &#034;fail&#034;).put(&#034;data&#034;, errinfo);<br \/>\n                }<br \/>\n                single.setCommunityId(community.getCommunityId());<br \/>\n                single.setTermName(data[i][col&#043;&#043;].toString());<br \/>\n                single.setHouseNo(data[i][col&#043;&#043;].toString());<br \/>\n                single.setUserName(data[i][col&#043;&#043;].toString());<br \/>\n                single.setSex(data[i][col&#043;&#043;].toString());<br \/>\n                single.setMobile(data[i][col&#043;&#043;].toString());<br \/>\n                single.setPersonType(data[i][col&#043;&#043;].toString());<br \/>\n                single.setRemark(data[i][col&#043;&#043;].toString());<br \/>\n                single.setCreater(user.getUsername());<br \/>\n                this.personService.save(single);<br \/>\n            } catch (Exception e) {<br \/>\n                e.printStackTrace();<br \/>\n            }<br \/>\n        }<br \/>\n        return Result.ok().put(&#034;status&#034;, &#034;success&#034;).put(&#034;data&#034;,&#034;\u6570\u636e\u5bfc\u5165\u5b8c\u6210&#xff01;&#034;);<br \/>\n    }<\/p>\n<h4 id=\"yR20-1754832139840\">1. \u5bfc\u51fa\u6570\u636e\u5230 Excel<\/h4>\n<p>&#064;GetMapping(&#034;\/exportExcel&#034;)<br \/>\npublic Result exportExcel(PersonListForm personListForm)<\/p>\n<p>\u6267\u884c\u6d41\u7a0b&#xff1a;<\/p>\n<p>1.\u83b7\u53d6\u6570\u636e<\/p>\n<p>\u8c03\u7528\u00a0personService.personList(personListForm)\u00a0\u6309\u6761\u4ef6\u5206\u9875\u67e5\u8be2\u6570\u636e&#xff0c;\u5f97\u5230\u00a0PageVO\u3002<\/p>\n<p>\u4ece\u00a0PageVO\u00a0\u4e2d\u53d6\u51fa\u00a0list&#xff08;\u8fd9\u5c31\u662f\u7b26\u5408\u6761\u4ef6\u7684\u4eba\u5458\u6570\u636e&#xff09;\u3002<\/p>\n<p>2.\u751f\u6210 Excel \u6587\u4ef6<\/p>\n<p>ExcelUtil.ExpPersonInfo(list, path)\u00a0\u5c06\u6570\u636e\u5199\u5165 Excel&#xff0c;\u5e76\u8fd4\u56de Excel \u6587\u4ef6\u7684\u4fdd\u5b58\u8def\u5f84\u3002<\/p>\n<p>3.\u8fd4\u56de\u7ed3\u679c<\/p>\n<p>Result.ok().put(&#034;data&#034;, path)\u00a0\u628a\u6587\u4ef6\u8def\u5f84\u8fd4\u56de\u7ed9\u524d\u7aef\u3002\u524d\u7aef\u53ef\u4ee5\u7528\u8fd9\u4e2a\u8def\u5f84\u4e0b\u8f7d Excel \u6587\u4ef6\u3002<\/p>\n<h4 id=\"Zes8-1754832183140\">2. \u4e0a\u4f20 Excel \u6587\u4ef6<\/h4>\n<p>&#064;PostMapping(&#034;\/excelUpload&#034;)<br \/>\npublic Result excelUpload(&#064;RequestParam(&#034;uploadExcel&#034;) MultipartFile file)<\/p>\n<p>\u6267\u884c\u6d41\u7a0b&#xff1a;<\/p>\n<p>1.\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u9009\u62e9<\/p>\n<p>\u5982\u679c\u00a0file.getOriginalFilename()\u00a0\u662f\u7a7a\u5b57\u7b26\u4e32&#xff0c;\u5c31\u76f4\u63a5\u8fd4\u56de\u00a0&#034;\u6ca1\u6709\u9009\u4e2d\u8981\u4e0a\u4f20\u7684\u6587\u4ef6&#034;\u3002<\/p>\n<p>2.\u751f\u6210\u65b0\u6587\u4ef6\u540d<\/p>\n<p>\u7528\u00a0UUID.randomUUID().toString()\u00a0\u751f\u6210\u4e00\u4e2a\u4e0d\u91cd\u590d\u7684\u6587\u4ef6\u540d\u3002\u83b7\u53d6\u539f\u6587\u4ef6\u540e\u7f00&#xff08;\u6bd4\u5982\u00a0.xls\u00a0\/\u00a0.xlsx&#xff09;&#xff0c;\u62fc\u63a5\u6210\u65b0\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<p>3.\u4fdd\u5b58\u6587\u4ef6\u5230\u670d\u52a1\u5668<\/p>\n<p>File targetFile &#061; new File(excel, newFileName)\u00a0\u521b\u5efa\u76ee\u6807\u6587\u4ef6\u5bf9\u8c61&#xff08;excel\u00a0\u662f\u5b58\u653e\u76ee\u5f55&#xff09;\u3002file.transferTo(targetFile)\u00a0\u628a\u4e0a\u4f20\u7684\u6587\u4ef6\u4fdd\u5b58\u5230\u6307\u5b9a\u76ee\u5f55\u3002<\/p>\n<p>4.\u8fd4\u56de\u7ed3\u679c<\/p>\n<p>\u628a\u65b0\u6587\u4ef6\u540d\u8fd4\u56de\u7ed9\u524d\u7aef&#xff0c;\u7528\u4e8e\u540e\u7eed\u89e3\u6790\u3002<\/p>\n<h4 id=\"dU6x-1754832245730\">3. \u4ece Excel \u5bfc\u5165\u6570\u636e\u5230\u6570\u636e\u5e93<\/h4>\n<p>&#064;PostMapping(&#034;\/parsefile\/{fileName}&#034;)<br \/>\npublic Result parsefile(&#064;PathVariable(&#034;fileName&#034;) String fileName,HttpSession session)<\/p>\n<p>\u6267\u884c\u6d41\u7a0b&#xff1a;<\/p>\n<h5 id=\"Dnsz-1754832273451\">\u6b65\u9aa4 1&#xff1a;\u51c6\u5907\u6587\u4ef6\u8bfb\u53d6<\/h5>\n<li>\u4ece\u00a0session\u00a0\u83b7\u53d6\u5f53\u524d\u767b\u5f55\u7528\u6237\u3002<\/li>\n<li>\u7ec4\u5408\u6587\u4ef6\u8def\u5f84\u00a0basePath &#061; excel &#043; fileName\u3002<\/li>\n<li>\u7528\u00a0Apache POI\u00a0\u6253\u5f00\u00a0.xls\u00a0\u6587\u4ef6&#xff1a;\n<li>POIFSFileSystem\u00a0\u2192 \u5904\u7406 Excel \u4e8c\u8fdb\u5236\u6d41\u3002<\/li>\n<li>HSSFWorkbook\u00a0\u2192 \u4ee3\u8868 Excel \u5de5\u4f5c\u7c3f\u5bf9\u8c61\u3002<\/li>\n<\/li>\n<h5 id=\"30ZS-1754832320744\" style=\"text-align:left\">\u6b65\u9aa4 2&#xff1a;\u628a Excel \u8f6c\u6210\u4e8c\u7ef4\u6570\u7ec4<\/h5>\n<li style=\"text-align:left\">\u53d6\u7b2c\u4e00\u4e2a\u5de5\u4f5c\u8868&#xff1a;wb.getSheetAt(0)\u3002<\/li>\n<li style=\"text-align:left\">\u83b7\u53d6\u603b\u884c\u6570\u548c\u603b\u5217\u6570\u3002<\/li>\n<li style=\"text-align:left\">\u8bbe\u5b9a\u00a0\u8df3\u8fc7\u8868\u5934&#xff08;\u8fd9\u91cc\u00a0headRow &#061; 2&#xff0c;\u610f\u601d\u662f\u524d\u4e24\u884c\u662f\u8868\u5934&#xff0c;\u4e0d\u8bfb&#xff09;\u3002<\/li>\n<li style=\"text-align:left\">\u521b\u5efa\u4e8c\u7ef4\u6570\u7ec4\u00a0data[r &#8211; headRow][c]\u00a0\u7528\u4e8e\u5b58\u50a8\u8868\u683c\u5185\u5bb9\u3002<\/li>\n<li style=\"text-align:left\">\u5faa\u73af\u6bcf\u4e00\u884c\u3001\u6bcf\u4e00\u5217&#xff1a;\n<li style=\"text-align:left\">\n<p>\u7528\u00a0DataFormatter\u00a0\u628a\u5355\u5143\u683c\u503c\u7edf\u4e00\u8f6c\u6210\u5b57\u7b26\u4e32<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u5982\u679c\u8bfb\u53d6\u5931\u8d25&#xff1a;<\/p>\n<li style=\"text-align:left\">\n<p>\u5148\u7f6e\u4e3a\u7a7a\u5b57\u7b26\u4e32<\/p>\n<\/li>\n<li style=\"text-align:left\">\n<p>\u5982\u679c\u662f\u7b2c\u4e00\u5217&#xff08;\u53ef\u80fd\u662f\u6570\u5b57 ID&#xff09;&#xff0c;\u5c1d\u8bd5\u7528\u00a0getNumericCellValue()\u00a0\u8f6c\u6210\u6574\u6570&#xff0c;\u518d\u8f6c\u5b57\u7b26\u4e32<\/p>\n<\/li>\n<\/li>\n<\/li>\n<h5 id=\"g4z6-1754832358376\" style=\"text-align:left\">\u6b65\u9aa4 3&#xff1a;\u89e3\u6790\u6570\u636e\u5e76\u5165\u5e93<\/h5>\n<li style=\"text-align: left\">\u904d<span style=\"background-color:null\">\u5386\u00a0data\u00a0\u6570\u7ec4\u7684<\/span>\u6bcf\u4e00\u884c&#xff1a;\n<li style=\"text-align: left\">\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u00a0Person\u00a0\u5bf9\u8c61<\/li>\n<li>\u56fa\u5b9a\u5b57\u6bb5\u521d\u59cb\u5316&#xff1a;personId&#061;0\u3001state&#061;1\u3001faceUrl&#061;&#034;&#034;<\/li>\n<\/li>\n<li>\u53d6\u51fa\u5c0f\u533a\u540d\u79f0\u00a0communityName&#xff0c;\u53bb\u00a0communityService\u00a0\u67e5\u8be2\u5bf9\u5e94\u7684\u5c0f\u533a ID&#xff1a;\n<li>\u5982\u679c\u4e0d\u5b58\u5728&#xff0c;\u7acb\u5373\u8fd4\u56de\u9519\u8bef\u00a0&#034;Excel\u6587\u4ef6\u7b2cX\u884c\u5c0f\u533a\u540d\u79f0\u4e0d\u5b58\u5728&#xff01;&#034;<\/li>\n<\/li>\n<li>\u586b\u5145\u5176\u4ed6\u5b57\u6bb5&#xff08;\u697c\u680b\u540d\u3001\u623f\u53f7\u3001\u59d3\u540d\u3001\u6027\u522b\u3001\u624b\u673a\u53f7\u3001\u5c45\u4f4f\u6027\u8d28\u3001\u5907\u6ce8\u7b49&#xff09;\u3002<\/li>\n<li>\u8bbe\u7f6e\u00a0creater\u00a0\u4e3a\u5f53\u524d\u767b\u5f55\u7528\u6237\u3002<\/li>\n<li>\u8c03\u7528\u00a0personService.save(single)\u00a0\u628a\u8fd9\u6761\u6570\u636e\u63d2\u5165\u6570\u636e\u5e93\u3002<\/li>\n<h5 id=\"ZPZD-1754832486450\">\u6b65\u9aa4 4&#xff1a;\u8fd4\u56de\u7ed3\u679c<\/h5>\n<p style=\"text-align:left\">\u5982\u679c\u6240\u6709\u6570\u636e\u90fd\u6210\u529f\u5bfc\u5165&#xff0c;\u8fd4\u56de&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;status&#034;: &#034;success&#034;,<br \/>\n  &#034;data&#034;: &#034;\u6570\u636e\u5bfc\u5165\u5b8c\u6210&#xff01;&#034;<br \/>\n}<\/p>\n<p style=\"text-align:left\">\u5982\u679c\u4e2d\u9014\u53d1\u73b0\u9519\u8bef&#xff08;\u6bd4\u5982\u5c0f\u533a\u4e0d\u5b58\u5728&#xff09;&#xff0c;\u63d0\u524d\u8fd4\u56de\u00a0&#034;status&#034;: &#034;fail&#034;\u00a0\u548c\u9519\u8bef\u4fe1\u606f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb103\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u524d\u7aef\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/123.jpg\u65f6\uff0cSpringboot\u4f1a\u6620\u5c04\u5230file:D:\/community\/upload\/face\/123.jpg\uff0c\u534f\u8bae\u7684\u5207\u6362\u548clocalhost:8080\u7684\u53d8\u52a8\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002\u8fd9\u610f\u5473\u7740\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/xxx.jpg \u65f6\uff0cSpring \u4f1a\u4ece D:\/community\/upload\/face\/xxx.jpg \u8bfb\u6587\u4ef6\u5e76\u8fd4\u56de\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,98,292],"topic":[],"class_list":["post-51357","post","type-post","status-publish","format-standard","hentry","category-server","tag-java","tag-spring-boot","tag-292"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/51357.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb103\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u524d\u7aef\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/123.jpg\u65f6\uff0cSpringboot\u4f1a\u6620\u5c04\u5230file:D:\/community\/upload\/face\/123.jpg\uff0c\u534f\u8bae\u7684\u5207\u6362\u548clocalhost:8080\u7684\u53d8\u52a8\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002\u8fd9\u610f\u5473\u7740\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/xxx.jpg \u65f6\uff0cSpring \u4f1a\u4ece D:\/community\/upload\/face\/xxx.jpg \u8bfb\u6587\u4ef6\u5e76\u8fd4\u56de\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51357.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T13:44:21+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51357.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51357.html\",\"name\":\"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T13:44:21+00:00\",\"dateModified\":\"2025-08-10T13:44:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51357.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51357.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51357.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/51357.html","og_locale":"zh_CN","og_type":"article","og_title":"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb103\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf7\u6b21\u3002\u524d\u7aef\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/123.jpg\u65f6\uff0cSpringboot\u4f1a\u6620\u5c04\u5230file:D:\/community\/upload\/face\/123.jpg\uff0c\u534f\u8bae\u7684\u5207\u6362\u548clocalhost:8080\u7684\u53d8\u52a8\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002\u8fd9\u610f\u5473\u7740\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost:8080\/community\/upload\/face\/xxx.jpg \u65f6\uff0cSpring \u4f1a\u4ece D:\/community\/upload\/face\/xxx.jpg \u8bfb\u6587\u4ef6\u5e76\u8fd4\u56de\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/51357.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T13:44:21+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51357.html","url":"https:\/\/www.wsisp.com\/helps\/51357.html","name":"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T13:44:21+00:00","dateModified":"2025-08-10T13:44:21+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51357.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51357.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51357.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"SpringBoot\u5b9e\u73b0\u6587\u4ef6\u4e0a\u4f20"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=51357"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51357\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51357"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}