我正在开发用于文件上传的API,并且需要代理。不使用代理时,只需添加config:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes 400m -->
<property name="maxUploadSize" value="419430400" />
</bean>
API将正常运行如下:
@RequestMapping(value = "/tags/build", method = RequestMethod.POST)
public Object buildTag(String repoName, String tag, @RequestParam(value = "dockerFile", required = true) MultipartFile dockerFile,
HttpServletRequest request, HttpServletResponse response) {
但添加代理,它不起作用,代理:
@RequestMapping("/**")
@ResponseBody
public String mirror(@RequestBody(required = false) String body, HttpMethod method, HttpServletRequest request, HttpServletResponse response) throws URISyntaxException {
...
try {
restTemplate.getMessageConverters().add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));
restTemplate.setRequestFactory(new CloudClientHttpRequestFactory(30000, 5000));
ResponseEntity<String> responseEntity = restTemplate.exchange(uri, HttpMethod.valueOf(request.getMethod()), entity, String.class);
String responseBody = responseEntity.getBody();
但是当我在代理web.xml中添加MultipartFilter时,它也可以工作。为什么?有什么身体可以帮助我吗?提前致谢。我用谷歌搜索,但找不到满意的答案。