当前位置:网站首页>JS cannot get content disposition in headers
JS cannot get content disposition in headers
2022-07-25 07:13:00 【Xiao Li loves programming】
Export download function
Problem recurrence
The front end realizes the export and download function
Here is the realization of Export function But when online There is The problem of export failure ;
We need to get the response header Content-Disposition Value of field , Separate the file name .

You can see here It's printed content-disposition

Online network You can also see that This filename ; But when I print it out from the request header , There is no such field ; So online export will fail 
To analyze problems
Browsers limit the exposure of this kind of request headers ; Therefore, it needs the cooperation of the server ;

Solution
Although this is added to the back end ; But we can only network see , Unable to get js Get it in the request header Content-Disposition
So you need to add a piece of code
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
effect
With this piece of code, you can export successfully ;
The back-end code is attached here

边栏推荐
- Baidu Post Bar crawler gets web pages
- Default value of dart variable
- 一日千里,追风逐月 | 深势科技发布极致加速版分子对接引擎Uni-Docking
- "Wei Lai Cup" 2022 Niuke summer multi school training camp 1 supplementary problem solution (incomplete)
- 30 times performance improvement -- implementation of MyTT index library based on dolphin DB
- Learn when playing No 7 | don't study this holiday, study only
- 【terminal】x86 Native Tools Command Prompt for VS 2017
- Electronic Association C language level 2 60, integer parity sort (real question in June 2021)
- Price reduction, game, bitterness, etc., vc/pe rushed to queue up and quit in 2022
- Ideal L9, can't cross a pit on the road?
猜你喜欢

Qt实战案例(53)——利用QDrag实现拖拽拼图功能

Ideal L9, can't cross a pit on the road?

Leetcode sword finger offer brush question notes

MySQL remote login
![[cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x](/img/7e/1d27e3f1856ab8c6cbfc5221c717bb.png)
[cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x

睡眠不足有哪些危害?

Will eating fermented steamed bread hurt your body

QT6 with vs Code: compiling source code and basic configuration

30 times performance improvement -- implementation of MyTT index library based on dolphin DB

Meta is in a deep quagmire: advertisers reduce spending and withdraw from the platform
随机推荐
【电脑讲解】去电脑维修店修电脑需要注意什么?
2022 Tiangong cup ctf--- crypto1 WP
阿里云镜像地址&网易云镜像
北京内推 | 微软STCA招聘NLP/IR/DL方向研究型实习生(可远程)
30 times performance improvement -- implementation of MyTT index library based on dolphin DB
List derivation
CEPH in hand, I have!
Two week learning results of machine learning
The relationship between Informatics, mathematics and Mathematical Olympiad (July 19, 2022) C
[computer explanation] what should I pay attention to when I go to the computer repair shop to repair the computer?
Rambus announces ddr5 memory interface chip portfolio for data centers and PCs
Basic usage of thread class
"Game illustrated book": a memoir dedicated to game players
Leetcode sword finger offer brush question notes
第一启富金怎么样
When importing data in batches, you always prompt "failure reason: SQL parsing failure: parsing file failure:: null". What's the matter?
【云原生】原来2020.0.X版本开始的OpenFeign底层不再使用Ribbon了
[computer explanation] NVIDIA released geforce RTX Super Series graphics cards, and the benefits of game players are coming!
Go basic notes_ 5_ Process statement
Price reduction, game, bitterness, etc., vc/pe rushed to queue up and quit in 2022