1

サーバーからクライアントに csv をストリームとして送信しようとしています。交換とダウンロードは正しく機能しますが、Chrome は常にコンソールに次のログを記録します。

Resource interpreted as Document but transferred with MIME type text/csv

クライアント要求は次のようになります。

<form class="feedbackCSVGenerator" method="get" action="my/url">
    <button type="submit" role="button"><span>Download as CSV</span></button>
</form>

そしてサーバー側の実装:

response.setContentType("text/csv");
response.setHeader("Content-Disposition",
            "attachment;filename=Feedback.csv");
response.setContentLength("Hello world".getBytes().length);
try {
    ServletOutputStream outStream = response.getOutputStream();
    outStream.write("Hello world".getBytes());
    outStream.close();
    response.flushBuffer();
} catch (IOException e) {
    //
}

別の MIME タイプを選択する必要がありますか、またはこのメッセージが表示されないようにするために設定できる別の応答ヘッダーはありますか? 特に影響はないようですが…

4

0 に答える 0