博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring文件上传配置
阅读量:4660 次
发布时间:2019-06-09

本文共 1136 字,大约阅读时间需要 3 分钟。

增加依赖jar包

commons-fileupload
commons-fileupload
1.3.1

修改springmvc.xml配置文件,添加

controller代码

package com.test.controller;import java.io.IOException;import java.util.List;import javax.annotation.Resource;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;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.multipart.MultipartFile;import org.springframework.web.servlet.ModelAndView;import net.sf.json.JSONObject;@Controllerpublic class ServiceDBController {	private static Log log = LogFactory.getLog(ServiceDBController.class);		@RequestMapping(value="test.do")	public void test(@RequestParam("myFile")MultipartFile myFile) {         //处理文件	}}

表单

  

转载于:https://www.cnblogs.com/sola/p/5088367.html

你可能感兴趣的文章
Mybatis缓存策略
查看>>
卷积的意义【转】
查看>>
android图形系统详解五:Android绘制模式
查看>>
[剑指offer] 23. 二叉搜索树的后序遍历序列
查看>>
canvas绘画交叉波浪
查看>>
Linux 内核分析
查看>>
试一下:XP ( SP2 ) 本身就支持查杀流氓软件!
查看>>
centos6(7) minimal 基本环境配置
查看>>
P2837晚餐队列安排
查看>>
DP专题
查看>>
UVa 1402 Runtime Error 伸展树
查看>>
笔记本安装SSD固态硬盘详细的优化设置
查看>>
批处理语法介绍
查看>>
FFmpeg 基础库(三)模块组成
查看>>
Linq 查询 与方法调用
查看>>
iOS开源项目(旧)
查看>>
winform的datagridview控件滚动更新数据
查看>>
java中Object类 源代码详解
查看>>
开源控Meteor的个人资料
查看>>
kafka在zookeeper中的存储结构
查看>>