学习SpringMVC(二十二)之文件上传
来源:互联网 发布:网络爬虫工具下载 编辑:程序博客网 时间:2024/06/06 05:44
文件上传的步骤:
1.在index.jsp中写一个表单:
<span style="font-family:SimSun;font-size:24px;"> <form action="springmvc/testFileUpload" method="POST" <span style="color:#ff0000;">enctype="multipart/form-data"></span>File: <input type="file" name="file"/>Desc: <input type="text" name="desc"/><input type="submit" value="Submit"/></form></span>
2.写一个controller:
<span style="font-family:SimSun;font-size:24px;">package com.cgf.springmvc.handlers;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.multipart.MultipartFile;@RequestMapping(value="/springmvc")@Controllerpublic class MyTestFileUpload {@RequestMapping(value="/testFileUpload")public String testFileUpload(<span style="color:#ff0000;">@RequestParam(value="file")MultipartFile file,</span>@RequestParam(value="desc")String desc){System.out.println(desc);System.out.println("file name:"+file.getOriginalFilename());return "success";}}</span>3.在springmvc.xml中配置CommonsMultipartResolver
<span style="font-family:SimSun;font-size:24px;"><bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"><property name="defaultEncoding" value="UTF-8"></property><property name="maxUploadSize" value="1024000"></property></bean></span>
0 0
- 学习SpringMVC(二十二)之文件上传
- SpringMVC学习之上传文件
- J2EE系列之Struts2学习笔记(二十二)--Struts2多文件上传和文件下载
- SpringMVC学习笔记四之文件上传
- SpringMVC学习---------文件上传
- SpringMVC学习 文件上传
- springMVC之文件上传
- springMVC之文件上传
- 【springMVC】之文件上传
- springMVC之文件上传
- springMVC之上传文件
- 文件上传之SpringMVC
- springmvc之文件上传
- springmvc之上传文件
- SpringMVC之文件上传
- SpringMVC中的文件上传 二
- J2EE系列之SpringMVC学习笔记(六)--文件上传
- Springmvc学习(07)-文件上传
- Struts2中Action的数据如何获取的
- redis3.0.0 集群安装详细步骤
- hadoop系列:zookeeper(2)——zookeeper核心原理(选举)
- 51单片机-定时器/计数器
- 【android】:android如何改变app图标
- 学习SpringMVC(二十二)之文件上传
- win下查看程序 的命令行 参数 类似linux ps -ef
- spring ,springMVC,Mybatis和ehcache整合遇到的问题
- 多核与多个CPU啥区别
- ADO.NET两种连接模型简介及增删改查实例
- 手把手教你实现 ListView
- Spring Security(02)——关于登录
- python os.path模块
- OnPreferenceChangeListener,OnPreferenceClickListener