When you click "I want to modify", You need to generate an excel file in the background and 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 ):
Copy codeThe 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: <basetarget = "_ self">, which indicates 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.
<Basetarget = _ blank> <! -- Open on a blank page -->
<Basetarget = _ parent> <! -- Open on the previous page of the current page (parent class) -->
<Basetarget = _ search> <! -- Open in the browser address bar -->
<Basetarget = _ self> <! -- Open on the current page -->
<Basetarget = _ top> <! -- Open on the initial (homepage) page -->
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.
Copy codeThe Code is as follows:
<Iframe id = "download" name = "download" height = "0px" width = "0px"> </iframe>
<Base target = "download">
<Base...> between