Fegin 多媒体上传调用
来源:互联网 发布:loadrunner11 java 编辑:程序博客网 时间:2024/06/08 06:29
先分享点小福利给程序员,阿里云的优惠券,购买服务器更便宜
点我获取阿里云优惠券
multipart/form-data
Spring MVC中关于关于Content-Type类型信息的使用 首先我们来看看RequestMapping中的Class定义:[html] view plain copy@Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Mapping public @interface RequestMapping { String[] value() default {}; RequestMethod[] method() default {}; String[] params() default {}; String[] headers() default {}; String[] consumes() default {}; String[] produces() default {}; } value: 指定请求的实际地址, 比如 /action/info之类。method: 指定请求的method类型, GET、POST、PUT、DELETE等consumes: 指定处理请求的提交内容类型(Content-Type),例如application/json, text/html;produces: 指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回params: 指定request中必须包含某些参数值是,才让该方法处理headers: 指定request中必须包含某些指定的header值,才能让该方法处理请求其中,consumes, produces使用content-typ信息进行过滤信息;headers中可以使用content-type进行过滤和判断。3. 使用示例 3.1 headers[html] view plain copy@RequestMapping(value = "/test", method = RequestMethod.GET, headers="Referer=http://www.ifeng.com/") public void testHeaders(@PathVariable String ownerId, @PathVariable String petId) { // implementation omitted } 这里的Headers里面可以匹配所有Header里面可以出现的信息,不局限在Referer信息。
public static void stream2Multi() throws Exception { // 读入 文件 File file = new File("E:\\模版0720.xls"); FileInputStream in_file = new FileInputStream(file); // 转 MultipartFile MultipartFile multi = new MockMultipartFile("模板.xls", in_file); String name = multi.getOriginalFilename(); // 创建文件夹 String dire = "E:/文件/picture/file.xls"; File file_dire = new File(dire); if (!file_dire.exists()) { file_dire.createNewFile(); } //写入文件 multi.transferTo(file_dire); }
org.springframework.web.multipart.MultipartException: Current request is not a multipart request at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:190) at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:109) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
Caused by: java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found at org.apache.catalina.connector.Request.parseParts(Request.java:2874) at org.apache.catalina.connector.Request.parseParameters(Request.java:3177) at org.apache.catalina.connector.Request.getParameter(Request.java:1110) at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ... 30 moreCaused by: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
我的官网
我的官网http://guan2ye.com
我的CSDN地址http://blog.csdn.net/chenjianandiyi
我的简书地址http://www.jianshu.com/u/9b5d1921ce34
我的githubhttps://github.com/javanan
我的码云地址https://gitee.com/jamen/
阿里云优惠券https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=vf2b5zld&utm_source=vf2b5zld
阿里云教程系列网站http://aliyun.guan2ye.com
我的开源项目spring boot 搭建的一个企业级快速开发脚手架
阅读全文
0 0
- Fegin 多媒体上传调用
- python微信八多媒体上传
- java上传多媒体文件
- C#调用多媒体定时器
- 手机多媒体--调用摄像头
- 调用 系统的多媒体 库
- Windows Phone 学习 调用多媒体
- Fegin 请求日志查看配置
- FCKEditor添加多媒体上传功能(转别人)
- HttpClient获取Accesstoken以及上传多媒体文件
- 微信公众号上传多媒体文件
- Android 多媒体应用:调用摄像头拍照
- spring cloud学习(四) Fegin 的使用
- spring cloud放弃系列之--4-fegin
- Spring cloud实战-Fegin简易使用
- 多媒体
- 多媒体
- 多媒体
- 设计模式六大原则小结
- Java时间戳与日期格式字符串的互转
- Jedis连接报错
- package.json 配置参数解释
- Maven清除LastUpdated文件
- Fegin 多媒体上传调用
- IT常识
- POJ2749 Building roads
- tp5判断是不是异地登录 简单版
- 前端冷知识(四):文件上传、线程、ajax
- Yii2安装高级模板
- 51nod 1220 约数之和
- dfs学习之扫雷问题
- 数人云|使微服务、容器趋向完美——Serverless架构你应当知道的二三事