Java 구현 파일 클릭 비반응 방법
프론트 데스크 aax 코드
Ext.Ajax.request({
url : '/yjy/training/TrainingTimeAction.do?method=downLoadAttchById',
params : {
timeId : timeids
},
success : function(response,options){
var result = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert(" ");
},
failure :function(response,options){
var result = Ext.util.JSON.decode(response.responseText);
Ext.Msg.alert(" "+result.message);
}
});
백그라운드 액션 코드
String timeId = request.getParameter("timeId");
String sql = "select doc_name from CPER.EHRTRAIN_item_DOCUMENT where item_id = ?";
DbHelper dbHelper = new DbHelper();
Object[] params = new Object[]{timeId};
String fileName = (String)dbHelper.runSQLScalar(sql, params);
String filePath = ServerPathUtil.getPathRoot()+"WEB-INF/cache/train_item_file/train_item_file_"+timeId+"/"+fileName;
File file = new File(filePath);
if(!file.exists()){
logger.debug(" ");
throw new IOException("the file not exists");
}
response.setContentLength((int) file.length());
OutputStream o = response.getOutputStream();
byte b[] = new byte[5000];
//response.setContentType("application/x-msdownload");
response.setContentType("application/vnd.ms-excel");
response.setContentLength((int)file.length());
response.setHeader("Content-Disposition","attachment; filename="+fileName);
FileInputStream in = new FileInputStream(file);
int n;
while ((n = in.read(b)) != -1) {
o.write(b, 0, n);
}
in.close();
}catch(Exception e){
e.printStackTrace();
}
해결 방법: 파일의 다운로드는 프론트에서 요청할 때form 폼 요청이나 윈도우로만 가능합니다.오픈의 방식, 마지막으로 나는 윈도우를 채택했다.오픈 방식
window.open('/yjy/training/TrainingTimeAction.do?method=downLoadAttchById&timeId=' + timeids);
주: 이 방식을 사용하면 페이지에 공백 창이 뜨고 다운로드하면 창이 자동으로 닫힙니다. 이 창을 표시하지 않으려면form으로 제출하십시오총결산
위에서 말한 것은 여러분이 소개한 자바 구현 파일 클릭이 반응하지 않는 방법입니다. 여러분께 도움이 되었으면 합니다. 만약에 궁금한 것이 있으면 저에게 메시지를 남겨 주십시오. 편집자는 제때에 답장을 드리겠습니다.여기에서도 저희 사이트에 대한 지지에 감사드립니다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
38. Java의 Leetcode 솔루션텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.