提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.servlet.controller; |
A |
2 |
|
|
3 |
import java.awt.image.BufferedImage; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileInputStream; |
|
6 |
import java.io.IOException; |
|
7 |
|
|
8 |
import javax.annotation.Resource; |
|
9 |
import javax.imageio.ImageIO; |
|
10 |
import javax.servlet.http.HttpServletRequest; |
|
11 |
import javax.servlet.http.HttpServletResponse; |
|
12 |
|
|
13 |
import org.springframework.stereotype.Controller; |
|
14 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
15 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
16 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
17 |
|
|
18 |
import com.mandi.common.RequestParam; |
|
19 |
import com.mandi.servlet.file.FileLoad; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author mengly |
|
23 |
* @version 创建时间:2015年6月28日 下午7:22:56 |
|
24 |
* 类说明 |
|
25 |
*/ |
|
26 |
@Controller("filedownload") |
|
27 |
@RequestMapping(value="/file/download",method={RequestMethod.GET,RequestMethod.POST}) |
|
28 |
public class Filedownload { |
|
29 |
@Resource |
|
30 |
private FileLoad fileload; |
|
31 |
|
|
32 |
|
|
33 |
@RequestMapping(value = "/down.htm", method = {RequestMethod.POST, RequestMethod.GET }) |
|
34 |
@ResponseBody |
|
35 |
public String down(HttpServletRequest r,HttpServletResponse re) |
|
36 |
{ |
|
37 |
String fileurl=RequestParam.getString(r, "fileurl"); |
|
38 |
String displayname=RequestParam.getString(r, "displayname"); |
|
39 |
fileurl=r.getServletContext().getRealPath(fileurl); |
|
40 |
fileload.downloadFile(displayname, fileurl, re); |
|
41 |
return null; |
|
42 |
} |
|
43 |
@RequestMapping(value = "/downr.htm", method = {RequestMethod.POST, RequestMethod.GET }) |
|
44 |
@ResponseBody |
|
45 |
public String downR(HttpServletRequest r,HttpServletResponse re) |
|
46 |
{ |
|
47 |
String fileurl=RequestParam.getString(r, "fileurl"); |
|
48 |
String displayname=RequestParam.getString(r, "displayname"); |
|
49 |
fileload.downloadFile(displayname, fileurl, re); |
|
50 |
return null; |
|
51 |
} |
|
52 |
|
|
53 |
@RequestMapping(value = "/viewimage.htm", method = {RequestMethod.POST, RequestMethod.GET }) |
|
54 |
@ResponseBody |
|
55 |
public String viewimage(HttpServletRequest r,HttpServletResponse re) |
|
56 |
{ |
|
57 |
String filepath=RequestParam.getString(r, "filepath"); |
|
58 |
try { |
|
59 |
BufferedImage img=null; |
|
60 |
img=ImageIO.read(new FileInputStream(new File(filepath))); |
|
61 |
ImageIO.write(img, "jpeg", re.getOutputStream()); |
|
62 |
} catch (IOException e) { |
|
63 |
e.printStackTrace(); |
|
64 |
} |
|
65 |
return null; |
|
66 |
} |
|
67 |
} |