sitelink1 | https://blog.naver.com/dmswn11kr/221075081694 |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
Content-disposition
: 컨텐트 타입의 옵션
: 지정된 파일명을 지정함으로써 더 자세한 파일의 속성을 알려줄 수 있다.
- inline
: 브라우저 인식 파일확장자를 가진 파일들에 대해서는 웹브라우저 상에서 바로 파일을 자동으로 보여줄 수 있어서 의미상인 멀티파트 마시지를 포현
: 그외의 파일들에 대해서는 '파일다운로드' 대화상자가 뜨도록 하는 해더속성
- attachment
: 브라우저 인식 파일확장자를 포함하여 모든 확장자의 파일들에 대해, 다운로드 시 무조건 '파일다운로드' 대화상자가 뜨도록 하는 해더속성
ex)
if (strClient.indexOf("MSIE 5.5") > -1) { // MS IE 5.5 이하
fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "\\ ");
response.setHeader("Content-Disposition", "filename=" + fileName + ".xls;");
} else if (strClient.indexOf("MSIE") > -1) { // MS IE (보통은 6.x 이상 가정)
fileName = java.net.URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "\\ ");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls;");
} else if (strClient.indexOf("Trident") > -1) { // MS IE 11
fileName = java.net.URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "\\ ");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls;");
} else { // 모질라, 오페라
fileName = new String(fileName.getBytes("euc-kr"), "latin1").replaceAll("\\+", "\\ ");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls;");
}