{"id":11259,"date":"2023-06-02T15:31:23","date_gmt":"2023-06-02T07:31:23","guid":{"rendered":"http:\/\/123.57.164.21\/?p=11259"},"modified":"2023-06-02T15:31:23","modified_gmt":"2023-06-02T07:31:23","slug":"spring-boot%e5%af%b9%e5%a4%9a%e6%96%87%e4%bb%b6%e5%a4%9a%e5%8f%82%e6%95%b0%e7%9a%84%e8%af%b7%e6%b1%82%e5%a4%84%e7%90%86%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=11259","title":{"rendered":"Spring Boot\u5bf9\u591a\u6587\u4ef6\u591a\u53c2\u6570\u7684\u8bf7\u6c42\u5904\u7406\u8bb0\u5f55"},"content":{"rendered":"\n<p>\u9879\u76ee\u80cc\u666f\uff1aspringboot \u9879\u76ee\u9047\u5230\u4e00\u4e2a\u9700\u6c42\uff0c\u9700\u8981\u4e0a\u4f20\u591a\u4e2a\u6587\u4ef6\u53ca\u76f8\u5173\u53c2\u6570\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u5de5\u5177\u8bf7\u6c42\u65b9\u5f0f\uff1aBody\u91cc\u9762\u8bbe\u7f6e\uff1amultipart\/form-data<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1024x558.png\" alt=\"\" class=\"wp-image-11260\" width=\"525\" height=\"285\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1024x558.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-300x163.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-768x418.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-830x452.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-230x125.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-350x191.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-480x261.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247.png 1318w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/figure><\/div>\n\n\n\n<p>\u6700\u5f00\u59cb\u6309\u4e0b\u9762\u65b9\u6cd5\u5b9a\u4e49<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    \/**\n     * \u4e0a\u4f20\u6587\u4ef6(\u65b0)\n     *\n     * @param fileUploadReq \u9644\u4ef6\u5173\u8054\u4fe1\u606f\n     * @return \u7ed3\u679c\n     *\/\n    @PostMapping(value = \"\/file\/upload\/new\", consumes = \n    MediaType.MULTIPART_FORM_DATA_VALUE)\n    public R&lt;FileRecord> uploadNew(@RequestBody FileUploadReq fileUploadReq);<\/pre>\n\n\n\n<p>\u4f1a\u51fa\u4e0b\u9762\u7684\u9519\u8bef<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Content type 'multipart\/form-data;boundary=--------------------------789428842947670377098484;charset=UTF-8' not supported<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-1024x543.png\" alt=\"\" class=\"wp-image-11261\" width=\"438\" height=\"232\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-1024x543.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-300x159.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-768x407.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-830x440.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-350x186.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1-480x255.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/06\/\u56fe\u7247-1.png 1388w\" sizes=\"(max-width: 438px) 100vw, 438px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ul><li><strong>\u4eceHttpServletRequest\u4e2d\u63d0\u53d6\u53c2\u6570<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n     * \u6587\u4ef6\u4e0a\u4f20\u8bf7\u6c42\n     *\/\n    @PostMapping(\"\/upload\/new\")\n    public R&lt;FileRecord> uploadNew(HttpServletRequest request) {\n        try {\n            MultipartHttpServletRequest params=((MultipartHttpServletRequest) request);\n            List&lt;MultipartFile> files = ((MultipartHttpServletRequest) request)\n                    .getFiles(\"fileList\");\n            String relationId = params.getParameter(\"relationId\");\n            String relationType = params.getParameter(\"relationType\");\n            \/\/ \u4e0a\u4f20\u5e76\u8fd4\u56de\u8bbf\u95ee\u5730\u5740\n \n            \/\/ TODO\n            return R.ok(new FileRecord());\n        } catch (Exception e) {\n            log.error(\"\u4e0a\u4f20\u6587\u4ef6\u5931\u8d25\", e);\n            return R.fail(e.getMessage());\n        }\n    }\n<\/pre>\n\n\n\n<ul><li><strong>\u76f4\u63a5\u7528\u5b9e\u4f53\u63a5\u6536<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n     * \u6587\u4ef6\u4e0a\u4f20\u8bf7\u6c42\n     *\/\n    @PostMapping(\"\/upload\/new\")\n    public R&lt;List&lt;FileRecord>> uploadNew(FileUploadReq fileUploadReq) {\n        try {\n            \/\/ \u4e0a\u4f20\u5e76\u8fd4\u56de\u8bbf\u95ee\u5730\u5740\n            List&lt;FileRecord> fileRecord = sysFileService.uploadFileNew(fileUploadReq);\n            return R.ok(fileRecord);\n        } catch (Exception e) {\n            log.error(\"\u4e0a\u4f20\u6587\u4ef6\u5931\u8d25\", e);\n            return R.fail(e.getMessage());\n        }\n    }\n<\/pre>\n\n\n\n<p>\u6ce8\u610f:\u8be5\u5904\u4e0d\u53ef\u4ee5\u7528 @<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=RequestBody&amp;spm=1001.2101.3001.7020\" target=\"_blank\">RequestBody<\/a> \u6ce8\u89e3\u63a5\u6536\uff0c\u6587\u4ef6\u7c7b\u578b\u8bf7\u6c42\u53ea\u80fd\u7528@RequestPart\u53ca@RequestParam\u6ce8\u89e3\u63a5\u6536\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<ul><li><strong>RequestParam<\/strong><\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@PostMapping(\"\/problem\")\n    public AjaxResult problemReport(@RequestParam(\"file\") List&lt;MultipartFile> files, \n        MaterialTaskProblemReportAddReq problemReportAddReq) {\n        reportManager.problemReport(files, problemReportAddReq);\n        return AjaxResult.success(\"\u65b0\u589e\u6210\u529f\");\n    }\n<\/pre>\n\n\n\n<p>\u867d\u7136\u8fd9\u6837\u53ef\u4ee5\u63a5\u6536\u5230\uff0c\u4f46\u8fd9\u6837\u5199\u5373\u4e0d\u597d\u7406\u89e3\u53c2\u6570\uff08\u4e0e\u8bf7\u6c42\u53c2\u6570\u683c\u5f0f\u4e0d\u5bf9\u5e94\uff09\uff0c\u53c8\u4e0d\u7b80\u6d01\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u80cc\u666f\uff1aspringboot \u9879\u76ee\u9047\u5230\u4e00\u4e2a\u9700\u6c42\uff0c\u9700\u8981\u4e0a\u4f20\u591a\u4e2a\u6587\u4ef6\u53ca\u76f8\u5173\u53c2\u6570\u4fe1\u606f\u3002 \u5de5\u5177\u8bf7\u6c42\u65b9\u5f0f\uff1aBody\u91cc\u9762 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11259"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11259"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11259\/revisions"}],"predecessor-version":[{"id":11263,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/11259\/revisions\/11263"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}