{"id":65015,"date":"2025-05-03T14:00:22","date_gmt":"2025-05-03T06:00:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65015\/"},"modified":"2025-05-03T14:00:22","modified_gmt":"2025-05-03T06:00:22","slug":"%e5%9c%a8-spring-boot-%e4%b8%ad%ef%bc%8csetcontenttype-%e5%af%b9%e5%9b%be%e7%89%87%e9%a2%84%e8%a7%88%e5%92%8c%e4%b8%8b%e8%bd%bd%e5%8a%9f%e8%83%bd%e7%9a%84%e5%bd%b1%e5%93%8d%e6%98%af%e4%bb%80-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65015\/","title":{"rendered":"\u5728 Spring Boot \u4e2d\uff0csetContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173103825189657.jpg\" class=\"aligncenter\" title=\"\u5728 Spring Boot \u4e2d\uff0csetContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"\u5728 Spring Boot \u4e2d\uff0csetContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>setContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd<\/strong><\/p>\n<p>\u5728 Spring Boot \u4e2d\uff0cresponse.setContentType() \u65b9\u6cd5\u7528\u4e8e\u8bbe\u7f6e\u54cd\u5e94\u7684\u5185\u5bb9\u7c7b\u578b\u3002\u5728\u5904\u7406\u56fe\u7247\u65f6\uff0c\u5bf9\u8be5\u65b9\u6cd5\u7684\u8c03\u7528\u4f4d\u7f6e\u4f1a\u5f71\u54cd\u56fe\u7247\u7684\u9884\u89c8\u6216\u4e0b\u8f7d\u529f\u80fd\u3002<\/p>\n<p><strong>\u9884\u89c8<\/strong><\/p>\n<p>\u5f53 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u653e\u5728\u83b7\u53d6\u8bfb\u53d6\u6587\u4ef6\u6d41\u5e76\u8d4b\u503c\u7ed9 putputStream \u4e4b\u540e\u8c03\u7528\u65f6\uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u54cd\u5e94\u7684\u5185\u5bb9\u89c6\u4e3a\u56fe\u50cf\uff0c\u5e76\u5c1d\u8bd5\u5728\u9875\u9762\u4e0a\u9884\u89c8\u3002\u8fd9\u662f\u56e0\u4e3a\u6d4f\u89c8\u5668\u6839\u636e\u54cd\u5e94\u7684\u5185\u5bb9\u7c7b\u578b\u6765\u51b3\u5b9a\u5982\u4f55\u5904\u7406\u54cd\u5e94\u7684\u5185\u5bb9\u3002<\/p>\n<p><strong>\u4e0b\u8f7d<\/strong><\/p>\n<p>\u76f8\u53cd\uff0c\u5f53 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u653e\u5728\u83b7\u53d6\u8bfb\u53d6\u6587\u4ef6\u6d41\u5e76\u8d4b\u503c\u7ed9 putputStream \u4e4b\u524d\u8c03\u7528\u65f6\uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u54cd\u5e94\u7684\u5185\u5bb9\u89c6\u4e3a\u4e0b\u8f7d\u6587\u4ef6\uff0c\u5e76\u5f39\u51fa\u6587\u4ef6\u4e0b\u8f7d\u5bf9\u8bdd\u6846\u4f9b\u7528\u6237\u4fdd\u5b58\u6587\u4ef6\u3002\u8fd9\u662f\u56e0\u4e3a\u6d4f\u89c8\u5668\u5728\u6b64\u60c5\u51b5\u4e0b\u5df2\u5c06\u54cd\u5e94\u5185\u5bb9\u89c6\u4e3a\u4e0b\u8f7d\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5f71\u54cd<\/strong><\/p>\n<p>\u56e0\u6b64\uff0c\u8c03\u7528 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u7684\u987a\u5e8f\u4f1a\u5f71\u54cd\u6d4f\u89c8\u5668\u5bf9\u54cd\u5e94\u5185\u5bb9\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u4ece\u800c\u5bfc\u81f4\u56fe\u7247\u9884\u89c8\u6216\u4e0b\u8f7d\u7684\u4e0d\u540c\u884c\u4e3a\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728 Spring Boot \u4e2d\uff0csetContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd\u662f\u4ec0\u4e48\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>setContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd \u5728 Spring Boot \u4e2d\uff0cresponse.setContentType() \u65b9\u6cd5\u7528\u4e8e\u8bbe\u7f6e\u54cd\u5e94\u7684\u5185\u5bb9\u7c7b\u578b\u3002\u5728\u5904\u7406\u56fe\u7247\u65f6\uff0c\u5bf9\u8be5\u65b9\u6cd5\u7684\u8c03\u7528\u4f4d\u7f6e\u4f1a\u5f71\u54cd\u56fe\u7247\u7684\u9884\u89c8\u6216\u4e0b\u8f7d\u529f\u80fd\u3002 \u9884\u89c8 \u5f53 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u653e\u5728\u83b7\u53d6\u8bfb\u53d6\u6587\u4ef6\u6d41\u5e76\u8d4b\u503c\u7ed9 putputStream \u4e4b\u540e\u8c03\u7528\u65f6\uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u54cd\u5e94\u7684\u5185\u5bb9\u89c6\u4e3a\u56fe\u50cf\uff0c\u5e76\u5c1d\u8bd5\u5728\u9875\u9762\u4e0a\u9884\u89c8\u3002\u8fd9\u662f\u56e0\u4e3a\u6d4f\u89c8\u5668\u6839\u636e\u54cd\u5e94\u7684\u5185\u5bb9\u7c7b\u578b\u6765\u51b3\u5b9a\u5982\u4f55\u5904\u7406\u54cd\u5e94\u7684\u5185\u5bb9\u3002 \u4e0b\u8f7d \u76f8\u53cd\uff0c\u5f53 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u653e\u5728\u83b7\u53d6\u8bfb\u53d6\u6587\u4ef6\u6d41\u5e76\u8d4b\u503c\u7ed9 putputStream \u4e4b\u524d\u8c03\u7528\u65f6\uff0c\u6d4f\u89c8\u5668\u4f1a\u5c06\u54cd\u5e94\u7684\u5185\u5bb9\u89c6\u4e3a\u4e0b\u8f7d\u6587\u4ef6\uff0c\u5e76\u5f39\u51fa\u6587\u4ef6\u4e0b\u8f7d\u5bf9\u8bdd\u6846\u4f9b\u7528\u6237\u4fdd\u5b58\u6587\u4ef6\u3002\u8fd9\u662f\u56e0\u4e3a\u6d4f\u89c8\u5668\u5728\u6b64\u60c5\u51b5\u4e0b\u5df2\u5c06\u54cd\u5e94\u5185\u5bb9\u89c6\u4e3a\u4e0b\u8f7d\u6587\u4ef6\u3002 \u5f71\u54cd \u56e0\u6b64\uff0c\u8c03\u7528 response.setContentType(&#8220;image\/*&#8221;) \u65b9\u6cd5\u7684\u987a\u5e8f\u4f1a\u5f71\u54cd\u6d4f\u89c8\u5668\u5bf9\u54cd\u5e94\u5185\u5bb9\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u4ece\u800c\u5bfc\u81f4\u56fe\u7247\u9884\u89c8\u6216\u4e0b\u8f7d\u7684\u4e0d\u540c\u884c\u4e3a\u3002 \u4ee5\u4e0a\u5c31\u662f\u5728 Spring Boot \u4e2d\uff0csetContentType \u5bf9\u56fe\u7247\u9884\u89c8\u548c\u4e0b\u8f7d\u529f\u80fd\u7684\u5f71\u54cd\u662f\u4ec0\u4e48\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-65015","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=65015"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65015\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}