http://blog.csdn.net/mmm333zzz/article/details/8569637 谢谢
近段时间在运用了spring mvc+spring3.x+mybatis3.x框架开发项目,碰到一个问题,上传图片并生成缩略图。在网上找了很多资料都没有看到我想要的功能,要不就单纯上传图片,而且代码简单没什么实用处。要不就是上传文件,不是我想找的。记得之前struts2也有上传图片生成高清缩略图的功能,于是看了看,有两种方法,不过大同小异。代码如下
以下是struts2也有上传图片哦。 如果要看 spring mvc上传图片 请直接拉下下
第一种:清晰度不高;
UploadAction
- package com.lanyuan.upload;
-
- import java.io.File;
- import com.opensymphony.xwork2.ActionSupport;
-
- public class UploadAction extends ActionSupport {
- private static final long serialVersionUID = -8204063374280945416L;
- private File upload;
- private String uploadFileName;
- private String uploadContentType;
- public String upload() throws Exception {
- UploadUtil uploadutil = new UploadUtil();
- uploadutil.uploadImage1(getUpload(), getUploadContentType(), getUploadFileName());
- return "success";
- }
- public File getUpload() {
- return upload;
- }
- public void setUpload(File upload) {
- this.upload = upload;
- }
- public String getUploadFileName() {
- return uploadFileName;
- }
- public void setUploadFileName(String uploadFileName) {
- this.uploadFileName = uploadFileName;
- }
- public String getUploadContentType() {
- return uploadContentType;
- }
- public void setUploadContentType(String uploadContentType) {
- this.uploadContentType = uploadContentType;
- }
- }
/**
*
* 上传图片 工具类
* 大图片路径,生成小图片路径,
* 大图片文件名,生成小图片文名,
* 生成小图片宽度,生成小图片高度,
* 是否等比缩放(默认为true))
*
* @author Administrator
*
*/
UploadUtil
- package com.lanyuan.upload;
-
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Random;
-
- import org.apache.struts2.ServletActionContext;
-
-
-
-
-
-
-
-
-
-
-
- public class UploadUtil {
- private String imagePath = "/image/"+new SimpleDateFormat("yyyyMMddHH").format(new Date())+"";
- private String image_smallPath = "/image_small/"+new SimpleDateFormat("yyyyMMddHH").format(new Date())+"";
-
-
-
-
-
-
-
-
-
-
- public void uploadImage1(File getUpload, String getUploadContentType, String getUploadFileName) throws IOException {
-
- String getImagePath = ServletActionContext.getServletContext().getRealPath(imagePath);
-
- String getImage_smallPath = ServletActionContext.getServletContext().getRealPath(image_smallPath);
- File image = new File(getImagePath);
- if (!image.exists()) {
- image.mkdir();
- }
- File image_small = new File(getImage_smallPath);
- if (!image_small.exists()) {
- image_small.mkdir();
- }
-
-
- String uploadName = getUploadContentType;
- System.out.println("图片类型 ------------"+uploadName);
-
- String lastuploadName = uploadName.substring(
- uploadName.indexOf("/") + 1, uploadName.length());
- System.out.println("得到上传文件的后缀名 ------------"+lastuploadName);
-
-
- String fileNewName = generateFileName(getUploadFileName);
- System.out.println("// 得到文件的新名字 ------------"+fileNewName);
-
- FileOutputStream fos = new FileOutputStream(getImagePath + "/" + fileNewName);
-
- FileInputStream fis = new FileInputStream(getUpload);
- byte[] buffer = new byte[1024];
- int len = 0;
- while ((len = fis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- DwindlePic mypic = new DwindlePic();
- mypic.s_pic(getImagePath + "/", getImage_smallPath + "/", fileNewName, fileNewName, 110, 110, false);
-
-
- imagePath = imagePath+"/"+fileNewName;
- image_smallPath = image_smallPath+"/"+fileNewName;
- }
-
-
-
-
-
-
-
- private String generateFileName(String fileName) {
- DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
- String formatDate = format.format(new Date());
- int random = new Random().nextInt(10000);
- int position = fileName.lastIndexOf(".");
- String extension = fileName.substring(position);
- return formatDate + random + extension;
- }
-
-
- public String getImagepath() {
- return imagePath;
- }
-
-
- public String getImageSmallpath() {
- return image_smallPath;
- }
- }
大图片路径,生成小图片路径,大图片文件名,生成小图片文名,生成小图片宽度,生成小图片高度,是否等比缩放(默认为true))
DwindlePic
- package com.lanyuan.upload;
-
- import java.io.*;
-
- import com.sun.image.codec.jpeg.*;
- import java.awt.image.*;
- import java.awt.*;
- import java.applet.*;
-
-
-
-
-
-
-
- public class DwindlePic {
- String InputDir;
- String OutputDir;
- String InputFileName;
- String OutputFileName;
- int OutputWidth = 110;
- int OutputHeight = 110;
- int rate = 0;
- boolean proportion = true;
-
- public DwindlePic() {
-
- InputDir = "";
- OutputDir = "";
- InputFileName = "";
- OutputFileName = "";
- OutputWidth = 110;
- OutputHeight = 110;
- rate = 0;
- }
-
- public boolean s_pic() {
-
-
-
- File file = new File(OutputDir + OutputFileName);
- FileOutputStream tempout = null;
- try {
- tempout = new FileOutputStream(file);
- } catch (Exception ex) {
- System.out.println(ex.toString());
- }
- Image img = null;
- Toolkit tk = Toolkit.getDefaultToolkit();
- Applet app = new Applet();
- MediaTracker mt = new MediaTracker(app);
- try {
- img = tk.getImage(InputDir + InputFileName);
- mt.addImage(img, 0);
- mt.waitForID(0);
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (img.getWidth(null) == -1) {
- System.out.println(" can't read,retry!" + "<BR>");
- return false;
- } else {
- int new_w;
- int new_h;
- if (this.proportion == true) {
-
- double rate1 = ((double) img.getWidth(null))
- / (double) OutputWidth + 0.1;
- double rate2 = ((double) img.getHeight(null))
- / (double) OutputHeight + 0.1;
- double rate = rate1 > rate2 ? rate1 : rate2;
- new_w = (int) (((double) img.getWidth(null)) / rate);
- new_h = (int) (((double) img.getHeight(null)) / rate);
- } else {
- new_w = OutputWidth;
- new_h = OutputHeight;
- }
- BufferedImage buffImg = new BufferedImage(new_w, new_h,
- BufferedImage.TYPE_INT_RGB);
- Graphics g = buffImg.createGraphics();
- g.setColor(Color.white);
- g.fillRect(0, 0, new_w, new_h);
- g.drawImage(img, 0, 0, new_w, new_h, null);
- g.dispose();
- JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(tempout);
- try {
- encoder.encode(buffImg);
- tempout.close();
- } catch (IOException ex) {
- System.out.println(ex.toString());
- }
- }
- return true;
- }
-
- public boolean s_pic(String InputDir, String OutputDir,
- String InputFileName, String OutputFileName) {
-
- this.InputDir = InputDir;
-
- this.OutputDir = OutputDir;
-
- this.InputFileName = InputFileName;
-
- this.OutputFileName = OutputFileName;
- return s_pic();
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public boolean s_pic(String InputDir, String OutputDir,
- String InputFileName, String OutputFileName, int width, int height,
- boolean gp) {
-
- this.InputDir = InputDir;
-
- this.OutputDir = OutputDir;
-
- this.InputFileName = InputFileName;
-
- this.OutputFileName = OutputFileName;
-
- setW_H(width, height);
-
- this.proportion = gp;
- return s_pic();
- }
-
- public void setInputDir(String InputDir) {
- this.InputDir = InputDir;
- }
-
- public void setOutputDir(String OutputDir) {
- this.OutputDir = OutputDir;
- }
-
- public void setInputFileName(String InputFileName) {
- this.InputFileName = InputFileName;
- }
-
- public void setOutputFileName(String OutputFileName) {
- this.OutputFileName = OutputFileName;
- }
-
- public void setOutputWidth(int OutputWidth) {
- this.OutputWidth = OutputWidth;
- }
-
- public void setOutputHeight(int OutputHeight) {
- this.OutputHeight = OutputHeight;
- }
-
- public void setW_H(int width, int height) {
- this.OutputWidth = width;
- this.OutputHeight = height;
- }
- }
看看效果吧!
第二种,清晰度还可以接受
- package com.xiyuan.upload;
-
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Random;
-
- import javax.imageio.ImageIO;
-
- import org.apache.struts2.ServletActionContext;
-
-
-
-
-
-
-
-
-
- public class UploadUtil
- {
- private String imagePath = "/imageFile/" + new SimpleDateFormat("yyyyMMddHH").format(new Date()) + "";
-
-
-
-
-
-
-
-
-
-
-
-
- public void uploadImage1(File getUpload, String getUploadContentType, String getUploadFileName) throws IOException
- {
-
- String getImagePath = ServletActionContext.getServletContext().getRealPath(imagePath);
-
- File image = new File(getImagePath);
- if (!image.exists())
- {
- image.mkdir();
- }
-
-
- String uploadName = getUploadContentType;
- System.out.println("图片类型 ------------" + uploadName);
-
- String lastuploadName = uploadName.substring(uploadName.indexOf("/") + 1, uploadName.length());
- System.out.println("得到上传文件的后缀名 ------------" + lastuploadName);
-
-
- String fileNewName = generateFileName(getUploadFileName);
- System.out.println("// 得到文件的新名字 ------------" + fileNewName);
-
-
-
-
-
-
-
-
-
-
-
-
- imagePath = imagePath + "/" + fileNewName;
- System.out.println(" 回图片路径 " + getUpload);
- System.out.println(" //最后返回图片路径 " + imagePath);
-
- BufferedImage srcBufferImage = ImageIO.read(getUpload);
- System.out.println(" w " + srcBufferImage.getWidth() + " w " + srcBufferImage.getHeight());
- BufferedImage scaledImage;
- ScaleImage scaleImage = ScaleImage.getInstance();
- int yw = srcBufferImage.getWidth();
- int yh = srcBufferImage.getHeight();
- int w = 110, h = 110;
-
- if (w > yw && h > yh)
- {
- FileOutputStream fos = new FileOutputStream(getImagePath + "/" + fileNewName);
-
- FileInputStream fis = new FileInputStream(getUpload);
- byte[] buffer = new byte[1024];
- int len = 0;
- while ((len = fis.read(buffer)) > 0)
- {
- fos.write(buffer, 0, len);
- }
- }
- else
- {
- scaledImage = scaleImage.imageZoomOut(srcBufferImage, w, h);
- FileOutputStream out = new FileOutputStream(getImagePath + "/" + fileNewName);
- ImageIO.write(scaledImage, "jpeg", out);
-
- }
- }
-
-
-
-
-
-
-
-
- private String generateFileName(String fileName)
- {
- DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
- String formatDate = format.format(new Date());
- int random = new Random().nextInt(10000);
- int position = fileName.lastIndexOf(".");
- String extension = fileName.substring(position);
- return formatDate + random + extension;
- }
-
- public String getImagepath()
- {
- return imagePath;
- }
-
- }
ScaleImage
- package com.xiyuan.upload;
-
-
- import java.awt.image.BufferedImage;
-
- public class ScaleImage {
- private int width;
-
- private int height;
-
- private int scaleWidth;
-
- private double support = (double) 3.0;
-
- private double PI = (double) 3.14159265358978;
-
- private double[] contrib;
-
- private double[] normContrib;
-
- private double[] tmpContrib;
-
- private int nDots;
-
- private int nHalfDots;
-
-
-
-
-
- private static ScaleImage instance = new ScaleImage();
- private ScaleImage(){};
- public static ScaleImage getInstance(){
- return instance;
- }
- public BufferedImage imageZoomOut(BufferedImage srcBufferImage, int w, int h) {
- width = srcBufferImage.getWidth();
- height = srcBufferImage.getHeight();
- scaleWidth = w;
-
- if (DetermineResultSize(w, h) == 1) {
- return srcBufferImage;
- }
- CalContrib();
- BufferedImage pbOut = HorizontalFiltering(srcBufferImage, w);
- BufferedImage pbFinalOut = VerticalFiltering(pbOut, h);
- return pbFinalOut;
- }
-
-
-
-
- private int DetermineResultSize(int w, int h) {
- double scaleH, scaleV;
- scaleH = (double) w / (double) width;
- scaleV = (double) h / (double) height;
-
- if (scaleH >= 1.0 && scaleV >= 1.0) {
- return 1;
- }
- return 0;
-
- }
-
- private double Lanczos(int i, int inWidth, int outWidth, double Support) {
- double x;
-
- x = (double) i * (double) outWidth / (double) inWidth;
-
- return Math.sin(x * PI) / (x * PI) * Math.sin(x * PI / Support)
- / (x * PI / Support);
-
- }
-
-
-
-
- private void CalContrib() {
- nHalfDots = (int) ((double) width * support / (double) scaleWidth);
- nDots = nHalfDots * 2 + 1;
- try {
- contrib = new double[nDots];
- normContrib = new double[nDots];
- tmpContrib = new double[nDots];
- } catch (Exception e) {
- System.out.println("init contrib,normContrib,tmpContrib" + e);
- }
-
- int center = nHalfDots;
- contrib[center] = 1.0;
-
- double weight = 0.0;
- int i = 0;
- for (i = 1; i <= center; i++) {
- contrib[center + i] = Lanczos(i, width, scaleWidth, support);
- weight += contrib[center + i];
- }
-
- for (i = center - 1; i >= 0; i--) {
- contrib[i] = contrib[center * 2 - i];
- }
-
- weight = weight * 2 + 1.0;
-
- for (i = 0; i <= center; i++) {
- normContrib[i] = contrib[i] / weight;
- }
-
- for (i = center + 1; i < nDots; i++) {
- normContrib[i] = normContrib[center * 2 - i];
- }
- }
-
-
- private void CalTempContrib(int start, int stop) {
- double weight = 0;
-
- int i = 0;
- for (i = start; i <= stop; i++) {
- weight += contrib[i];
- }
-
- for (i = start; i <= stop; i++) {
- tmpContrib[i] = contrib[i] / weight;
- }
-
- }
-
- private int GetRedValue(int rgbValue) {
- int temp = rgbValue & 0x00ff0000;
- return temp >> 16;
- }
-
- private int GetGreenValue(int rgbValue) {
- int temp = rgbValue & 0x0000ff00;
- return temp >> 8;
- }
-
- private int GetBlueValue(int rgbValue) {
- return rgbValue & 0x000000ff;
- }
-
- private int ComRGB(int redValue, int greenValue, int blueValue) {
-
- return (redValue << 16) + (greenValue << 8) + blueValue;
- }
-
-
- private int HorizontalFilter(BufferedImage bufImg, int startX, int stopX,
- int start, int stop, int y, double[] pContrib) {
- double valueRed = 0.0;
- double valueGreen = 0.0;
- double valueBlue = 0.0;
- int valueRGB = 0;
- int i, j;
-
- for (i = startX, j = start; i <= stopX; i++, j++) {
- valueRGB = bufImg.getRGB(i, y);
-
- valueRed += GetRedValue(valueRGB) * pContrib[j];
- valueGreen += GetGreenValue(valueRGB) * pContrib[j];
- valueBlue += GetBlueValue(valueRGB) * pContrib[j];
- }
-
- valueRGB = ComRGB(Clip((int) valueRed), Clip((int) valueGreen),
- Clip((int) valueBlue));
- return valueRGB;
-
- }
-
-
- private BufferedImage HorizontalFiltering(BufferedImage bufImage, int iOutW) {
- int dwInW = bufImage.getWidth();
- int dwInH = bufImage.getHeight();
- int value = 0;
- BufferedImage pbOut = new BufferedImage(iOutW, dwInH,
- BufferedImage.TYPE_INT_RGB);
-
- for (int x = 0; x < iOutW; x++) {
-
- int startX;
- int start;
- int X = (int) (((double) x) * ((double) dwInW) / ((double) iOutW) + 0.5);
- int y = 0;
-
- startX = X - nHalfDots;
- if (startX < 0) {
- startX = 0;
- start = nHalfDots - X;
- } else {
- start = 0;
- }
-
- int stop;
- int stopX = X + nHalfDots;
- if (stopX > (dwInW - 1)) {
- stopX = dwInW - 1;
- stop = nHalfDots + (dwInW - 1 - X);
- } else {
- stop = nHalfDots * 2;
- }
-
- if (start > 0 || stop < nDots - 1) {
- CalTempContrib(start, stop);
- for (y = 0; y < dwInH; y++) {
- value = HorizontalFilter(bufImage, startX, stopX, start,
- stop, y, tmpContrib);
- pbOut.setRGB(x, y, value);
- }
- } else {
- for (y = 0; y < dwInH; y++) {
- value = HorizontalFilter(bufImage, startX, stopX, start,
- stop, y, normContrib);
- pbOut.setRGB(x, y, value);
- }
- }
- }
-
- return pbOut;
-
- }
-
- private int VerticalFilter(BufferedImage pbInImage, int startY, int stopY,
- int start, int stop, int x, double[] pContrib) {
- double valueRed = 0.0;
- double valueGreen = 0.0;
- double valueBlue = 0.0;
- int valueRGB = 0;
- int i, j;
-
- for (i = startY, j = start; i <= stopY; i++, j++) {
- valueRGB = pbInImage.getRGB(x, i);
-
- valueRed += GetRedValue(valueRGB) * pContrib[j];
- valueGreen += GetGreenValue(valueRGB) * pContrib[j];
- valueBlue += GetBlueValue(valueRGB) * pContrib[j];
-
-
-
-
- }
-
- valueRGB = ComRGB(Clip((int) valueRed), Clip((int) valueGreen),
- Clip((int) valueBlue));
-
- return valueRGB;
-
- }
-
- private BufferedImage VerticalFiltering(BufferedImage pbImage, int iOutH) {
- int iW = pbImage.getWidth();
- int iH = pbImage.getHeight();
- int value = 0;
- BufferedImage pbOut = new BufferedImage(iW, iOutH,
- BufferedImage.TYPE_INT_RGB);
-
- for (int y = 0; y < iOutH; y++) {
-
- int startY;
- int start;
- int Y = (int) (((double) y) * ((double) iH) / ((double) iOutH) + 0.5);
-
- startY = Y - nHalfDots;
- if (startY < 0) {
- startY = 0;
- start = nHalfDots - Y;
- } else {
- start = 0;
- }
-
- int stop;
- int stopY = Y + nHalfDots;
- if (stopY > (int) (iH - 1)) {
- stopY = iH - 1;
- stop = nHalfDots + (iH - 1 - Y);
- } else {
- stop = nHalfDots * 2;
- }
-
- if (start > 0 || stop < nDots - 1) {
- CalTempContrib(start, stop);
- for (int x = 0; x < iW; x++) {
- value = VerticalFilter(pbImage, startY, stopY, start, stop,
- x, tmpContrib);
- pbOut.setRGB(x, y, value);
- }
- } else {
- for (int x = 0; x < iW; x++) {
- value = VerticalFilter(pbImage, startY, stopY, start, stop,
- x, normContrib);
- pbOut.setRGB(x, y, value);
- }
- }
-
- }
-
- return pbOut;
-
- }
-
- private int Clip(int x) {
- if (x < 0)
- return 0;
- if (x > 255)
- return 255;
- return x;
- }
-
-
-
-
-
-
- }
看看第二种效果怎样。。
呵呵,,第二种不错吧! 好了,以上是struts2上传图片生成高清缩略图,接下来就是如何利用spring mvc 来完成这个功能了。。
首先spring MVC没有 ServletActionContext.getServletContext().getRealPath(imagePath); 这个获取上下文的方法。你也可以自己写一个,,
但可以用request啊。有现成的何必再自己写呢!呵呵
request.getSession().getServletContext().getRealPath(imagePath); 用这个代替,当然方法逆天必需传入request
第二:
BufferedImage srcBufferImage = ImageIO.read(getUpload); 这个方法 传入getUpload是file 类型,但spring MVC 中MultipartFile 只有这个类型。所以行不通。查了查API,
发现ImageIO.read(getUpload); 可以传入InputStream的。所以只要修改一下multipartFile.getInputStream()就OK。。 最后一点:同样道
理 把 FileInputStream fis = new FileInputStream(getUpload); 修改为 FileInputStream fis = (FileInputStream) multipartFile.getInputStream();好吧!贴上源码: ScaleImage
这个类不变。。只修改一下UploadUtil
- package com.lanyuan.upload;
-
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Random;
-
- import javax.imageio.ImageIO;
- import javax.servlet.http.HttpServletRequest;
-
- import org.springframework.web.multipart.MultipartFile;
-
-
-
-
-
-
-
-
-
- public class UploadUtil
- {
- private String imagePath = "/imageFile/" + new SimpleDateFormat("yyyyMMddHH").format(new Date()) + "";
-
-
-
-
-
-
-
-
-
-
-
-
- public void uploadImage1(HttpServletRequest request,MultipartFile file, String getUploadContentType, String getUploadFileName) throws IOException
- {
-
- String getImagePath = request.getSession().getServletContext().getRealPath(imagePath);
-
- File image = new File(getImagePath);
- if (!image.exists())
- {
- image.mkdir();
- }
-
-
- String uploadName = getUploadContentType;
- System.out.println("图片类型 ------------" + uploadName);
-
- String lastuploadName = uploadName.substring(uploadName.indexOf("/") + 1, uploadName.length());
- System.out.println("得到上传文件的后缀名 ------------" + lastuploadName);
-
-
- String fileNewName = generateFileName(getUploadFileName);
- System.out.println("// 得到文件的新名字 ------------" + fileNewName);
-
-
-
-
-
-
-
-
-
-
-
-
- imagePath = imagePath + "/" + fileNewName;
- System.out.println(" 回图片路径 " + file.getInputStream());
- System.out.println(" //最后返回图片路径 " + imagePath);
-
- BufferedImage srcBufferImage = ImageIO.read(file.getInputStream());
- System.out.println(" w " + srcBufferImage.getWidth() + " w " + srcBufferImage.getHeight());
- BufferedImage scaledImage;
- ScaleImage scaleImage = ScaleImage.getInstance();
- int yw = srcBufferImage.getWidth();
- int yh = srcBufferImage.getHeight();
- int w = 400, h = 300;
-
- if (w > yw && h > yh)
- {
- FileOutputStream fos = new FileOutputStream(getImagePath + "/" + fileNewName);
-
- FileInputStream fis = (FileInputStream) file.getInputStream();
- byte[] buffer = new byte[1024];
- int len = 0;
- while ((len = fis.read(buffer)) > 0)
- {
- fos.write(buffer, 0, len);
- }
- }
- else
- {
- scaledImage = scaleImage.imageZoomOut(srcBufferImage, w, h);
- FileOutputStream out = new FileOutputStream(getImagePath + "/" + fileNewName);
- ImageIO.write(scaledImage, "jpeg", out);
-
- }
- }
-
-
-
-
-
-
-
-
- private String generateFileName(String fileName)
- {
- DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
- String formatDate = format.format(new Date());
- int random = new Random().nextInt(10000);
- int position = fileName.lastIndexOf(".");
- String extension = fileName.substring(position);
- return formatDate + random + extension;
- }
-
- public String getImagepath()
- {
- return imagePath;
- }
-
- }
最后如何调用:请看:很简单
- @RequestMapping ("upload")
- public String upload(Model model,HttpServletRequest request)
- {
-
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-
- MultipartFile imgFile1 = multipartRequest.getFile("imgFile");
-
- UploadUtil uploadutil = new UploadUtil();
- String fileName = imgFile1.getOriginalFilename();
- try {
- uploadutil.uploadImage1(request, imgFile1, imgFile1.getContentType(), fileName);
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- return "redirect:query";
- }