나는 바니시 캐시를 * .doc * .png * .xls와 같은 일부 파일을 사용합니다.바니시 캐시에서 올바른 .xls 파일을 얻는 방법은 무엇입니까?
캐시에서 파일을 가져 오는 동안 * .xls 파일은 정상적으로 작동합니다.
내 URI는 /attachment/show?fileId=ewer232ewe2121eeddsd
입니다. 캐시에서 .xls 파일을 요청하면 show
whitout 확장명의 파일이 반환됩니다.
내 서버 코드는 다음과 같습니다
if (StringUtil.null2Trim(attachment.getExtension()).equals("doc")
|| StringUtil.null2Trim(attachment.getExtension()).equals("docx")
|| StringUtil.null2Trim(attachment.getExtension()).equals("xlsx")
|| StringUtil.null2Trim(attachment.getExtension()).equals("xls")) {
response.setHeader("Content-Disposition", "attachment; filename=\""
+ StringUtil.gbk2Iso(attachment.getName()) + "\"");
if (StringUtil.null2Trim(attachment.getExtension()).indexOf("doc") != -1) {
response.setContentType("application/msword");
}
if (StringUtil.null2Trim(attachment.getExtension()).indexOf("xls") != -1) {
response.setContentType("application/vnd.ms-excel");
}
} else {
if (StringUtil.null2Trim(attachment.getExtension()).equals("jpg")) {
response.setContentType("image/jpeg");
} else if (StringUtil.null2Trim(attachment.getExtension()).equals("png")) {
response.setContentType("image/x-png");
} else {
response.setContentType("image/" + attachment.getExtension());
}
}
내 질문은 : 나는 attachment.getName()+".xls"
처럼 올바른 파일 이름을 얻을 수없고, 왜 그 해결 방법.
추 신 : 니스 (vcl)에서 ContentType을 설정하는 방법이 있습니까?
이 메시지는 Varnish가 아니라 백엔드 서버 애플릿의 문제와 같습니다. 서버가 반환 한 정확한 헤더는 무엇입니까? – Ketola
@Ketola 예, 서버가 잘못된 헤더를 설정했습니다. 이제 제대로 작동합니다. – lichengwu