美文网首页
@RequestPart和@RequestParam的区别

@RequestPart和@RequestParam的区别

作者: 扣篮的左手 | 来源:发表于2021-10-09 12:18 被阅读0次

使用multipart/form-data编码类型向后端同时传文件和JSON等其他类型数据时会用到@RequestPart注解,这里粗略的说一下两者的区别(语言上描述不够严谨)

@RequestPart注解的MultipartFile类型参数使用MultipartResolver关联,其它的类型的参数使用HttpMessageConverter(类似@RequestBody)
@RequestParam注解的非String或MultipartFile/Part类型,转换器需要一个注册的Converter 或 PropertyEditor

参考 https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/annotation/RequestPart.html

相关文章

网友评论

      本文标题:@RequestPart和@RequestParam的区别

      本文链接:https://www.haomeiwen.com/subject/gbrqoltx.html