第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用Spring Rest模板+ Spring Web MVC分段上傳文件

使用Spring Rest模板+ Spring Web MVC分段上傳文件

慕的地8271018 2019-12-27 15:36:04
我正在嘗試使用帶有以下代碼的RestTemplate上傳文件。   MultiValueMap<String, Object> multipartMap = new LinkedMultiValueMap<>();   multipartMap.add("file", new ClassPathResource(file));   HttpHeaders headers = new HttpHeaders();   headers.setContentType(new MediaType("multipart", "form-data"));   HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<MultiValueMap<String, Object>>(multipartMap, headers);   System.out.println("Request for File Upload : " + request);   ResponseEntity<byte[]> result = template.get().exchange(                    contextPath.get() + path, HttpMethod.POST, request,                    byte[].class);我有MultipartResolverbean,控制器代碼是@RequestMapping(value = "/{id}/image", method = RequestMethod.POST)@ResponseStatus(HttpStatus.NO_CONTENT)@Transactional(rollbackFor = Exception.class)public byte[] setImage(@PathVariable("id") Long userId,        @RequestParam("file") MultipartFile file) throws IOException {    // Upload logic}我得到以下異常 org.springframework.web.bind.MissingServletRequestParameterException: Required MultipartFile parameter 'file' is not present        at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:255) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]        at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:95) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]        at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:79) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]        at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 805 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)