java springboot 方法返回 header, javascript 可访问

var servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
var response = servletRequestAttributes.getResponse();
var filename = "a.xls";
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode( filename, "UTF-8"));

 

posted on 2022-08-02 10:40  空明流光  阅读(732)  评论(0编辑  收藏  举报

导航