`
yjgyjg4
  • 浏览: 118957 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

java下载

    博客分类:
  • java
阅读更多
public ActionForward downloadDocFile(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		String recordId = request.getParameter("recordId");
		Integer docRecordId;
		try {
			docRecordId = new Integer(recordId);
		} catch (Exception e) {
			docRecordId = null;
		}
		if (docRecordId != null) {

			CamDoc cd = camDocControl.findByRecordID(new Integer(recordId));

			byte[] doc = cd.getDocObject();

			response.setContentType("application/octet-stream; charset=GBK");
			response.setContentLength(doc.length);
			response.setHeader("Content-disposition",
					"attachment; filename="
							+ new String(cd.getFileName().getBytes("GBK"),
									"ISO-8859-1"));
			response.getOutputStream().write(doc);

		}
		return null;
	}
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics