springMVC easyUI filebox 单个文件上传
来源:互联网 发布:调查问卷哪个最赚 知乎 编辑:程序博客网 时间:2024/06/15 20:42
被这个文件上传坑到现在,还是自己技术问题,照着之前extjs项目那边的上传实例,愣是上传不了
到后面就查了下springMVC的文件上传,按照那样搞定了http://blog.csdn.net/jadyer/article/details/7575934
easyui 前端文件
<form id="brandAddForm" method="post" enctype="multipart/form-data"> <table cellpadding="5"> <tr> <td>名称:</td> <td><input class="easyui-textbox" type="text" name="name" data-options="required:true" style="width:200px"></input></td> </tr> <tr> <td>描述:</td> <td><input class="easyui-textbox" name="description" data-options="multiline:true" style="height:100px;width:200px"></input></td> </tr> <tr> <td>URL:</td> <td><input class="easyui-textbox" name="url" style="width:200px"></td> </tr> <tr> <td>LOGO:</td> <td><input class="easyui-filebox" name="sourceFile" style="width:200px"></td> </tr> <tr> <td>关键词:</td> <td><input class="easyui-textbox" type="text" name="keywords" data-options="" style="width:200px"></input></td> </tr> </table></form>
springMVC 配置文件
<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="UTF-8"/> <!-- 指定所上传文件的总大小不能超过200KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 --> <property name="maxUploadSize" value="200000"/> </bean> <!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException --> <!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 --> <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/jsp/error_fileupload.jsp页面 --> <prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error_fileupload</prop> </props> </property> </bean>
model
public class BrandModel {private Integer id;private String name;private String description;private String url;private String icon;private MultipartFile sourceFile; //对应<span style="font-family: Arial, Helvetica, sans-serif;"><input class="easyui-filebox" name="sourceFile" style="width:200px"></span> //set/get}
service 复制到你自己的目录
FileUtils.copyInputStreamToFile(brandModel.getSourceFile().getInputStream(), new File(targetPath));
0 2
- springMVC easyUI filebox 单个文件上传
- easyUI filebox文件上传
- easyui filebox限制文件上传的类型
- easyui filebox限制文件上传的类型
- easyui filebox限制文件上传的类型
- easyui easyui-filebox 上传文件按钮 更改为汉字
- springmvc 单个文件上传
- MVC项目使用easyui的filebox控件上传文件
- easyui filebox限制文件上传的类型accept (新旧版本)
- easyui filebox 上传图片预览
- easyui的filebox过滤文件
- SpringMVC实现单个文件上传
- 使用EasyUI 的上传文件控件 easyui-filebox 获取其数据的问题
- jQuery easyui-filebox+ajax+PHP实现文件上传并恢复备份
- 用easyui-filebox上传Excel文件(ASP.NET MVC)[附源码下载]
- jQuery EasyUI filebox的文件路径错误
- easyui和springmvc上传文件
- EasyUI file-box+SpringMVC 单个或多个图片上传
- win7 ubuntu 双系统卸载ubuntu
- sql cookbook 2.3 按字串排序问题
- iOS求职之C语言面试题
- ios block一定会犯的几个错误
- OpenCV2.49+VisualStudio2010开发环境配置
- springMVC easyUI filebox 单个文件上传
- iOS archive(归档)的总结
- iOS开发之17个常用代码整理
- HDU 1520 Anniversary party 树形DP
- 微信如何添加精准粉丝
- 1~20的整数的全排列
- 微软发布.NET平台免费的图表Chart控件 [转载]
- iOS清除推送的消息
- maven常用命令