资源简介

springMVC文件上传完美 demo,自带 jar包, 前后台代码 ,表单上传,项目直接导入即可!

资源截图

代码片段和文件信息

package com.action;
import java.io.*;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.bean.Photo;
@Controller
public class PhotoAction {
@RequestMapping(value=“upload.do“)
public String upload(HttpServletRequest requestHttpServletResponse responsePhoto pt){
String rpath=request.getRealPath(“/“);
System.out.println(pt.gettitle());
System.out.println(pt.getUname());
System.out.println(pt.getFile());
System.out.println(“======================“);

// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;     
// MultipartFile multipartFile = multipartRequest.getFile(“file“);   
MultipartFile multipartFile = pt.getFile();   
File file=new File(rpath+“/aa.jpg“);
try {
multipartFile.transferTo(file);
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

System.out.println(“上传成功!“);

return null;
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        853  2017-06-23 14:34  springmvc文件上传\prjSpringupload\.classpath

     文件        318  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.mymetadata

     文件       1966  2017-06-23 14:51  springmvc文件上传\prjSpringupload\.project

     文件        500  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\.jsdtscope

     文件        364  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\org.eclipse.jdt.core.prefs

     文件        483  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\org.eclipse.wst.common.component

     文件        252  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2017-06-23 14:32  springmvc文件上传\prjSpringupload\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件        462  2017-06-23 14:34  springmvc文件上传\prjSpringupload\.springBeans

     文件       1175  2017-06-23 15:36  springmvc文件上传\prjSpringupload\src\applicationContext.xml

     文件       1393  2017-06-23 15:37  springmvc文件上传\prjSpringupload\src\com\action\PhotoAction.java

     文件        840  2017-06-23 15:32  springmvc文件上传\prjSpringupload\src\com\bean\Photo.java

     文件       1249  2017-06-23 15:21  springmvc文件上传\prjSpringupload\WebRoot\index.jsp

     文件         36  2017-06-23 14:32  springmvc文件上传\prjSpringupload\WebRoot\meta-INF\MANIFEST.MF

     文件       1175  2017-06-23 15:36  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\applicationContext.xml

     文件       2173  2017-06-23 15:37  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\com\action\PhotoAction.class

     文件       1344  2017-06-23 15:32  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\com\bean\Photo.class

     文件      57779  2017-11-07 08:56  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\lib\commons-fileupload-1.2.1.jar

     文件     159509  2017-06-23 14:54  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\lib\commons-io-2.0.1.jar

     文件      75574  2017-06-23 14:34  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\spring-form.tld

     文件      17344  2017-06-23 14:34  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\spring.tld

     文件       1032  2017-06-23 15:36  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\springmvc-servlet.xml

     文件        991  2017-06-23 14:51  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\web.xml

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\com\action

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\com\bean

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes\com

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\src\com\action

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\src\com\bean

     目录          0  2017-11-07 09:42  springmvc文件上传\prjSpringupload\WebRoot\WEB-INF\classes

............此处省略13个文件信息

评论

共有 条评论