spring mvc MultipartFile 上传文件 当文件较小时(10k) ,无法上传成功 。
<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"/>
<!-- 指定所上传文件的总大小不能超过200KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
<property name="maxUploadSize" value="1024000"/>
<property name="fileItemFactory.sizeThreshold" value="0"></property>
</bean>
查看该类源码
有一段说明文档
* <p>Provides "maxUploadSize", "maxInMemorySize" and "defaultEncoding" settings as
* bean properties (inherited from {@link CommonsFileUploadSupport}). See corresponding
* ServletFileUpload / DiskFileItemFactory properties ("sizeMax", "sizeThreshold",
* "headerEncoding") for details in terms of defaults and accepted values.
进入 CommonsFileUploadSupport
public abstract class CommonsFileUploadSupport {
protected final Log logger = LogFactory.getLog(getClass());
private final DiskFileItemFactory fileItemFactory;
private final FileUpload fileUpload;
private boolean uploadTempDirSpecified = false;
进入
DiskFileItemFactory 类
看到
/**
* The threshold above which uploads will be stored on disk.
*/
private int sizeThreshold = DEFAULT_SIZE_THRESHOLD;//DEFAULT_SIZE_THRESHOLD=10240就是10k
设置下这个参数即可。
spring mvc MultipartFile 上传文件 当文件较小时(10k) ,无法上传成功 。的更多相关文章
- Spring MVC程序中得到静态资源文件css,js,图片文件的路径问题总结
上一篇 | 下一篇 Spring MVC程序中得到静态资源文件css,js,图片 文件的路径 问题总结 作者:轻舞肥羊 日期:2012-11-26 http://www.blogjava.net/fi ...
- Spring Mvc 笔记二之异常和文件上传
spring mvc的异常与文件上传 1.异常: spring注解版的异常有局部异常和全局异常 1.局部异常对单个controller有效;(在controller类写一 ...
- Spring MVC MultipartFile实现图片上传
<!--Spring MVC xml 中配置 --><!-- defaultEncoding 默认编码;maxUploadSize 限制大小--><!-- 配置Multi ...
- Spring MVC程序中得到静态资源文件css,js,图片
转载自:http://www.blogjava.net/fiele/archive/2014/08/24/417283.html 用 Spring MVC 开发应用程序,对于初学者有一个很头疼的问题, ...
- Spring MVC - MultipartFile实现文件上传(单文件与多文件上传)
准备工作: 需要先搭建一个spirngmvc的maven项目 1.加入jar包 <dependency> <groupId>commons-fileupload</gro ...
- spring mvc MultipartFile 上传文件错误解决
Field error in object 'xxxx' on field 'xxxx': rejected value [20129259128131.jpg]; codes [typeMismat ...
- Strut2 和Spring MVC 文件上传对比
在Java领域中,有两个常用的文件上传项目:一个是Apache组织Jakarta的Common-FileUpload组件 (http://commons.apache.org/proper/commo ...
- spring mvc 3.0 实现文件上传功能
http://club.jledu.gov.cn/?uid-5282-action-viewspace-itemid-188672 —————————————————————————————————— ...
- 基于Spring MVC的文件上传和下载功能的实现
配置文件中配置扫描包,以便创建各个类的bean对象 <context:component-scan base-package="com.neuedu.spring_mvc"& ...
随机推荐
- css选择器, first-child,first-of-type
选择制定的classname var li = $('.list-tab-group li.active'); <ul class="list-tab-group"> ...
- 文件的编辑命令-echo/cat
touch test.yaml echo "line1 line2" >> test.yaml cat test.yaml line1 line2 # 创建test.y ...
- python入门-异常
1 报错的例子 print(5/0) 2跳过报错的例子 try: print(5/0) except ZeroDivisionError: print("You can't divide b ...
- Zabbix监控系统端口
参考网站: https://www.cnblogs.com/nulige/p/7072019.html
- Win7 系统还原
Win7 由于某种原因,第二天开机不正常,桌面配置丢失,桌面上的文档不见了. 这种情况不要怕. 可以在启动界面F8,进入系统还原,然后选择某个时间点还原成功!!! 错误描述: Windows 不能加载 ...
- Eclipse launch configuration----Eclipse运行外部工具
虽然我们已经有了像 Eclipse 这样高级的 IDE,但是我们有时候也是需要在开发的时候使用 Windows 的命令行,来运行一些独立的程序.在两个程序中切换来切换去是很麻烦的.所以 Eclipse ...
- ios push local notification
UILocalNotification* localNotification = [[UILocalNotification alloc]init]; localNotification.alertB ...
- JAVA中request.getParameterMap()用法笔记
一. 根据Java规范:request.getParameterMap()返回的是一个Map类型的值,该返回值记录着前端(如jsp页面)所提交请求中的请求参数和请求参数值的映射关系.这个返回值有个特别 ...
- one by one 项目 part 2
在网上百度了一下mySQL常用语句 ,整理如下: 1.说明:创建数据库 CREATE DATABASE database-name 2.说明:删除数据库 drop database dbname 3. ...
- HP LaserJet MFP M227_M231双面打印
双面打印设置