Home  >  Article  >  Web Front-end  >  Usage example of showModelDialog pop-up file download window_jquery

Usage example of showModelDialog pop-up file download window_jquery

WBOY
WBOYOriginal
2016-05-16 17:14:11953browse

When you click I want to modify, the excel file needs to be generated in the background, and the file download function needs to be provided.
It is easy to generate excel files, and it is also easy to pop up "File Download":
Click the button to jump to the action, generate the Excel file in the action, fill in the data, save it to a temporary folder, and then click on the button In the Click event, generate an Excel report based on the template, fill in the data, save it to a temporary folder, and then output.wirte(). Everything seems to be going well.
The Action is as follows (the "File Download" window pops up):

Copy code The code is as follows:

/**
*@paramresponse
*@paramdownloadFile
*/
privatevoidclientResponse (HttpServletResponseresponse,FiledownloadFile,StringfileName){
try{
response.reset();
response.setContentType("application/octet-stream");

//Used to pop up the save window, set to attachment
response.setHeader("Content-Disposition","attachment;filename=" newString(fileName.getBytes(),"ISO-8859-1")) ;
InputStreaminput=newFileInputStream(downloadFile);
OutputStreamoutput=response.getOutputStream();
intc;
//Read the stream and write it to the file
while((c=input .read())!=-1){
output.write(c);
}
output.flush();
output.close();
input.close( );
}catch(Exceptione){
}
}

But when testing, I found that when I clicked the "I want to modify" button, a new window would always pop up. Baidu added this paragraph: , which means opening the page on the current page.
As follows:
base: Specifies the default address or default target for all links on the page
target: The target page to jump to





This problem is solved, but a new problem arises, that is, the file cannot be downloaded. So is there a way that I can open it on this page and provide downloading at the same time? The iframe framework came to mind. We can set up an invisible iframe, and then target=iframName can solve the problem.

Copy code The code is as follows:



This is located between
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn