我正在使用Struts2
下载文件。当我点击按钮下载文件时,文件会自动下载并在Excel中打开,而我希望它下载,当我右键单击它时,我应该可以打开或保存它。在IE
和Firefox
中,我会打开一个窗口来打开或保存文件,但在Chrome
中,文件文件会自动在Excel中打开。有没有办法在Chrome
Firefox
和IE
public String viewReport() throws Exception {
boolean returnReport;
inputStream = new FileInputStream(DOCUSIGN_REPORT_FILE);
try {
returnReport = validateRequest();
if (returnReport) {
intgList = this.generateViewIntegrationReportData(getESignUIConfig());
this.createCSVFile(intgList, DOCUSIGN_REPORT_FILE);
} else {
failureResponse(msgs, 400);
return null;
}
} catch (Exception e) {
e.printStackTrace();
msgs.add(new Message(ESignatureIntegrationMessageTypeEnum.MESSAGE_TYPE_ERROR,
UiIntegrationKeyConstants.UI_INTEGRATION_ERROR_CODE_500, UiIntegrationKeyConstants.UI_INTEGRATION_ERROR_TEXT_SERVICE_ERROR));
failureResponse(msgs, 500);
return null;
}
return UiIntegrationKeyConstants.REPORT_REPSONSE;
}
动作
<action name="*Integration" method="{1}" class="foo.bar.ESignatureIntegrationAction">
<result name="success" type="tiles">integrationView</result>
<result name="reportResponse" type="stream">
<param name="contentType">application/text/csv</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">
attachment;filename="DocuSignEnvelopeReport.csv"
</param>
<param name="bufferSize">4096</param>
</result>
</action>
struts.xml中
#include <iostream>
#include <queue>
int main() {
int tree[] = {5, 9, 11, 14, 18, 19, 21, 33, 17, 27};
int size = 10;
std::queue <int> q;
q.push(0);
bool flag = true;
while(!q.empty()) {
int x = q.front();
q.pop();
int left = 2*x+1, right = 2*x+2; // 0-based indexing used here
if(left < size) { // check if left child exists or not.
q.push(left);
// check value at parent is less than child or not.
if(tree[x] > tree[left]) {
flag = false;
break;
}
}
if(right < size) { // check whether right child exists or not.
q.push(right);
if(tree[x] > tree[right]) { // check value of parent less than child.
flag = false;
break;
}
}
}
if(flag)
std::cout << "It is minimum heap.\n";
else
std::cout << "Not a minimum heap.\n";
return 0;
}