81,092
社区成员
发帖
与我相关
我的任务
分享
public class DownloadFileAction extends DownloadAction {
private static String contentType = "application/file";
@SuppressWarnings("unchecked")
@Override
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 下载的文件名
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
String FileName = sDateFormat.format(new java.util.Date()) + ".data";
// 下载方式
response.addHeader("Content-Disposition", "attachment; filename="
+ FileName);
// WEBSERVICE取得数据
DownloadFileBiz sa = new DownloadFileBiz();
String hex = "";
try {
// 接受获得的数据
hex = sa.getFileInfo(inUseList, version);
return new ByteStreamInfo(CommonWebUtil.hexStr2bytes(hex),
contentType);
} catch (StationBizException e) {
// 当BIZ有异常的时候跳转错误页面
StationException se = new StationException(e);
se.setActionForward(mapping
.findForward(StationWebConst.FORWARD_ERROR));
throw se;
}
}
hex = sa.getFileInfo(inUseList, version);
StreamInfo si = new ByteStreamInfo(CommonWebUtil.hexStr2bytes(hex),
contentType);
response.addHeader("Content-Disposition", "attachment; filename="
+ FileName);
return si;