Java 如何在react to application/json中设置内容类型
我的代码如下所示 它总是变成文本/纯文本;字符集=UTF-8 我发现cors的支持只是Java 如何在react to application/json中设置内容类型,java,reactjs,http,Java,Reactjs,Http,我的代码如下所示 它总是变成文本/纯文本;字符集=UTF-8 我发现cors的支持只是 application/x-www-form-urlencoded multipart/form-data text/plain 但是我想将json发送到Http req。如何修复它?问题是您设置了错误的HTTP头以接受JSON作为响应。您应设置的标题为“接受”: axios.get('my/url', { headers: { 'Content-Type': 'applicat
application/x-www-form-urlencoded
multipart/form-data
text/plain
但是我想将json发送到Http req。如何修复它?问题是您设置了错误的HTTP头以接受JSON作为响应。您应设置的标题为“接受”:
axios.get('my/url', {
headers: {
'Content-Type': 'application/json',
Accept: 'application/json'
}
})