//JAVA端,从流写到文件
String path = AzUpLoadConstants.UP_BOOKORDER_QRCODE_URL + order.getShopId() + "/" + String.valueOf(billNo);
File f = new File(Mvcs.getServletContext().getRealPath(path + "/1.png"));
Files.write(f, ar.getInputStream());
//返回路径JSON
return path + "/1.png";
第一次前端报错404
VM1344:1 Failed to load image http://localhost:8080/test/qrcode/1/BK1-2003110001/1.png?v=0.8105500422015619
the server responded with a status of 404 (HTTP/1.1 404)
From server ::1
微信小程序的Headers
Request URL: http://localhost:8080/test/qrcode/1/BK1-2003110001/1.png?v=0.8105500422015619
Request Method: GET
Status Code: 404
Remote Address: [::1]:8080
Referrer Policy: no-referrer-when-downgrade
Content-Language: zh-CN
Content-Length: 1110
Content-Type: text/html;charset=utf-8
Date: Wed, 11 Mar 2020 08:30:53 GMT
X-Powered-By: nutz/1.r.68.v20190329 <nutzam.com>
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: localhost:8080
Referer: https://servicewechat.com/wx1933d256f98883c7/devtools/page-frame.html
Sec-Fetch-Dest: image
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?F
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1 wechatdevtools/1.02.1911180 MicroMessenger/7.0.4 Language/zh_CN webview/42 miniprogram port/50506 token/728d74aad8322102cd6c3a623b130414
但这时在浏览器访问图片网址:http://localhost:8080/test/qrcode/bookorder/1/BK1-2003110001/1.png?v=0.8105500422015619
是可以访问到图片的。
难道Files.write()写完文件,还没有刷新导致前端404吗?
请大神解析一下,谢谢