Преглед на файлове

git-svn-id: https://192.168.57.71/svn/jsgkj@828 931142cf-59ea-a443-aa0e-51397b428577

ld_xuhx преди 8 години
родител
ревизия
1b52fdbed1

+ 2 - 2
gkjsjy/trunk/WebContent/WEB-INF/pages/gkjygl/gkjyr/xkzxx/xkzxxedit.jsp

@@ -149,7 +149,7 @@
 							 </div>
 							 <div id="fjxq1">
 						      
-	                <span id='fzmc1'><a class='main_title' href='${app }/accessory/download?id=${record.zmpicid}'>${record.zmpicname }</a></span>
+	                <span id='fzmc1'><a class='main_title' href='${app }/accessory/downloadXkz?id=${record.zmpicid}'>${record.zmpicname }</a></span>
 	                <a class="main_title" onclick="xkzxx.detail.delFj('${record.zmpicid}','1')" class='btn btn-default btn-xs'><i class='glyphicon glyphicon-trash'></i>删除</a>
 	                 </div>
 						
@@ -161,7 +161,7 @@
 							 <a href="#" id="fzfm"  style="display: none"  class="file"><input type="file" name="fmpic" id="fmpic"   onchange="xkzxx.detail.saveFile2()">上传扫描件反面</a>
 							 </div>
 							  <div id="fjxq2">
-							    <span id='fzmc2'><a class='main_title' href='${app }/accessory/download?id=${record.fmpicid}'>${record.fmpicname }</a></span>
+							    <span id='fzmc2'><a class='main_title' href='${app }/accessory/downloadXkz?id=${record.fmpicid}'>${record.fmpicname }</a></span>
 	                			<a class="main_title" onclick="xkzxx.detail.delFj('${record.fmpicid}','2')" class='btn btn-default btn-xs'><i class='glyphicon glyphicon-trash'></i>删除</a>
 						     </div>
 						   </c:if>

+ 1 - 2
gkjsjy/trunk/WebContent/static/biz/js/gkjygl/gkjyr/xkzxx/xkzxxdetail.js

@@ -303,7 +303,6 @@ xkzxx.detail.saveFile1 = function(){
 	        url : $.app + '/xkzxx/saveFz',
 	        success : function(data, status) {
 	            var file = $('#zmpic');
-	           
 	            file.after(file.clone().val(""));
 	            file.remove();
 	            if (data) {
@@ -356,7 +355,7 @@ xkzxx.detail.saveFile2 = function(){
 	                $('#fmpicid').val(accid);
 	                var str = "";
 	                str = "<span id='fzmc2'>" 
-	                      + "<a class='main_title' href='/jsjy/accessory/download?id="+ accid +"'> " + accContect +"</a>"+"</span>";
+	                      + "<a class='main_title' href='/jsjy/accessory/downloadXkz?id="+ accid +"'> " + accContect +"</a>"+"</span>";
 	                str+="<a class='main_title' onclick=\"xkzxx.detail.delFj('"+ accid +"','"+i+"');\" class='btn btn-default btn-xs'><i class='glyphicon glyphicon-trash'></i>图片</a>"
 	                $("#fjxq2").empty();
 	                $("#fjxq2").append(str);

+ 29 - 0
gkjsjy/trunk/src/com/xt/jygl/accessory/ctl/AccessoryCtl.java

@@ -84,6 +84,35 @@ public class AccessoryCtl extends BaseWebCtl {
 		}
 		return null;
 	}
+	
+	/**
+	 * 附件下载
+	 * 
+	 */
+	@RequestMapping(value = "/downloadXkz", method = RequestMethod.GET)
+	public WebJsonResult handleFormDownloadXkz(String id, Model model, HttpServletRequest request, HttpServletResponse response) {
+		try {
+			AccessoryEntity entity = accessoryService.findOne(id);
+			if(entity != null){
+				// path是指欲下载的文件的路径。
+				String path = GlobalData.VIEW_FILE_PATH + entity.getFilepath() + entity.getFilename();
+				// 以流的形式下载文件。
+				InputStream fis = new BufferedInputStream(new FileInputStream(path));
+				byte[] buffer = new byte[fis.available()];
+				fis.read(buffer);
+				fis.close();
+				// 设置response的Header
+				response.setCharacterEncoding("utf-8");
+				response.setContentType("multipart/form-data");
+				String fileName = URLEncoder.encode(entity.getName(), "UTF-8");
+				response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
+				response.getOutputStream().write(buffer);
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
 
 	/**
 	 * 删除处理