spring-mvc 上传具有不同名称的多个部分
例子
可以上传多个部分,每个部分都有不同的名称。对于每个零件名称,您需要一个用注释的参数@RequestPart,其名称与零件名称匹配。
要接收通过HTTPPost上传的文件,您需要执行以下操作:
@RequestMapping(
value = "...",
method = RequestMethod.POST,
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public Object uploadFile(
@RequestPart MultipartFile profilePicture,
@RequestPart MultipartFile companyLogo,
) {
.
.
.
}作为HTML:
作为原始HTTP请求:
POST /... HTTP/1.1 Host: ... Content-Type: multipart/form-data; boundary=----------287032381131322 ------------287032381131322 Content-Disposition: form-data; name="profilePicture"; filename="r.gif" Content-Type: image/gif GIF87a.............,...........D..; ------------287032381131322 Content-Disposition: form-data; name="companyLogo"; filename="banana.jpeg" Content-Type: image/jpeg GIF87a.............,...........D..; ------------287032381131322--
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短