[英]download file instead of opening in browser using struts2
我已经在struts2中编写了文件上传和下载。 但是,当我下载在浏览器页面中打开的text.pdf
文件时,如何下载文件而不是在浏览器页面中打开?
<div class="block-fluid table-sorting clearfix">
<table cellpadding="0" cellspacing="0" width="100%" class="table" id="tSortable">
<thead>
<tr>
<th>S. No</th>
<th>ACCOUNT NO</th>
<th>FILE </th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<s:iterator value="fileuploadlist" status="rowstatus" >
<tr>
<td><s:property value="#rowstatus.index+1" /></td>
<td><s:property value="fileupload_temp2" /></td>
<td><s:property value="fileupload_filename"/></td>
<td><s:a href="%{fileupload_filepath}" target="_blank" >download</s:a> </td>
</tr>
</s:iterator>
</tbody>
</table>
</div>
您可以强制下载,但是必须从服务器端进行下载 :实现自己的端点(例如servlet),该端点将返回此标头以及所请求的文件:
content-disposition: attachment; filename="suggested-filename"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.