簡體   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