Example of how to use the showModelDialog pop-up File Download window _ jquery

Source: Internet
Author: User
This article mainly introduces the example of how to use the showModelDialog pop-up File Download window. The method is very simple. You can directly refer to the following code to use it. When you click "I want to modify", You need to generate an excel file in the background, you must also provide the file download function.
It is easy to generate an excel file and pop-up "File Download:
Click the button to jump to the action. In this action, an Excel file is generated, data is filled, and saved to a Temporary Folder. In the Click Event of the button, an Excel report is generated based on the template, fill in the data, save it to the temporary folder, and then output. wirte (). Everything looks good.
The Action is as follows (the "File Download" window is displayed ):

The Code is as follows:


/**
* @ Paramresponse
* @ ParamdownloadFile
*/
PrivatevoidclientResponse (HttpServletResponseresponse, FiledownloadFile, StringfileName ){
Try {
Response. reset ();
Response. setContentType ("application/octet-stream ");

// The save window is displayed and 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 (effectione ){
}
}

However, during the test, a new window is always displayed when I click the "I want to modify" button. Baidu: This indicates that the page is opened 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.





This problem has been solved, but the new problem is that files cannot be downloaded. So is there any way I can open or download on this page? Think of the iframe framework. We can set an invisible iframe framework, and then target = iframName can solve the problem.

The Code is as follows:




This Located inBetween

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.