报错详细:
Unhandled Rejection (TypeError): Failed to execute 'setRequestHeader' on 'XMLHttpRequest': Value is not a valid ByteString.
报错原因:
是请求头中存在汉字
解决方案:
我们前段可以使用Base64进行编码 encodeURI() 这个函数,然后后端对这个Base64进行解码,具体函数如下:
public String decode(String url) {
String prevURL = "";
String decodeURL = url;
while (!prevURL.equals(decodeURL)) {
prevURL = decodeURL;
decodeURL = URLDecoder.decode(decodeURL, StandardCharsets.UTF_8);
}
return decodeURL;
}
来源:CSDN
作者:骑鱼的猫咪
链接:https://blog.csdn.net/qq_39820860/article/details/103807786