繁体   English   中英

所需的字符串参数“graphName”不存在

[英]Required String parameter 'graphName' is not present

var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        console.log("excel download");
      }
    };
    xhttp.open("POST", "exportGraphExcel", true);
    xhttp.setRequestHeader("Content-type", "application/msexcel");
    xhttp.send('graphName=graphakki');

它在浏览器中给出 400 状态。 如果 Content-type 更改为“application/x-www-form-urlencoded”,则接受请求。

请求标头中的内容类型是您发送的内容。 您发送的不是 Excel 文件,而是请求 Excel 文件。

当您发送"application/x-www-form-urlencoded"内容类型标头时,您是在告诉服务器您的参数必须在 URL 中读取( 这是标准方式)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM