package com.test.controller;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import com.test.utils.DateUtils;
@Controller
@RequestMapping("/file")
public class FileController {
@RequestMapping(value = "/savefile", method = RequestMethod.POST)
@ResponseBody
public Object saveFiles(HttpSession session, HttpServletRequest request,
@RequestParam("files") MultipartFile file) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
String filepath = "D:/springmvc/test/";
if (null != file) {
if (!new File(filepath).exists()) {
new File(filepath).mkdirs();
}
String names = DateUtils.getTime("yyyyMMddHHmmss")
+ file.getOriginalFilename();
System.out.println(filepath + names);
File tarFile = new File(filepath, names);
file.transferTo(tarFile);
}
map.put("msg", "success");
return map;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
uploadifive SpringMVC文件上传Demo
共50个文件
jar:27个
class:3个
java:3个
5星 · 超过95%的资源 需积分: 33 154 下载量 108 浏览量
2015-10-08
15:18:36
上传
评论 6
收藏 8.62MB RAR 举报
温馨提示
Springmvc利用uploadifive插件,文件上传,方便使用.支持多文件上传.
资源推荐
资源详情
资源评论
收起资源包目录
uploadifive.rar (50个子文件)
uploadifive
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.wst.common.component 482B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 364B
src
com
test
init
SystemParameterInit.java 1KB
controller
FileController.java 2KB
utils
DateUtils.java 393B
.project 1KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1KB
spring-servlet.xml 2KB
lib
validation-api-1.1.0.CR1.jar 62KB
spring-beans-4.0.0.RELEASE.jar 654KB
classmate-0.8.0.jar 58KB
spring-core-4.0.0.RELEASE.jar 933KB
jackson-annotations-2.1.5.jar 34KB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
aopalliance-1.0.jar 4KB
spring-jdbc-4.0.0.RELEASE.jar 410KB
standard.jar 384KB
spring-context-4.0.0.RELEASE.jar 928KB
jackson-databind-2.1.5.jar 906KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
jackson-core-2.1.5.jar 202KB
jboss-logging-3.1.1.GA.jar 59KB
spring-aop-4.0.0.RELEASE.jar 343KB
jstl.jar 20KB
spring-expression-4.0.0.RELEASE.jar 202KB
commons-logging-1.1.3.jar 61KB
hibernate-validator-5.0.0.CR2.jar 565KB
commons-fileupload-1.2.1.jar 56KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
spring-orm-4.0.0.RELEASE.jar 309KB
spring-aspects-4.0.0.RELEASE.jar 50KB
spring-tx-4.0.0.RELEASE.jar 242KB
spring-web-4.0.0.RELEASE.jar 646KB
commons-io-2.0.jar 156KB
hibernate-validator-annotation-processor-5.0.0.CR2.jar 63KB
static
css
uploadifive.css 2KB
uploadifive-cancel.png 1KB
images
uploadifive-cancel.png 1KB
js
jquery.uploadifive.min.js 13KB
jquery-1.8.0.min.js 90KB
index.jsp 1KB
.classpath 841B
build
classes
com
test
init
SystemParameterInit.class 2KB
controller
FileController.class 3KB
utils
DateUtils.class 939B
共 50 条
- 1
李瑞豆豆
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页