方法1:它接受实体和图像作为请求参数
@RequestMapping(value="/add", method={RequestMethod.POST}, params={"entity", "image"})
public String add( @RequestParam("entity") CustomEntity entity,
@RequestParam("image") MultipartFile image) {
LOGGER.trace("Information with Image");
return "success";
}
方法2:它只接受实体和图像的请求参数
@RequestMapping(value="/add", method={RequestMethod.POST}, params={"entity")
public String add( @RequestParam("entity") CustomEntity entity) {
LOGGER.trace("Information without Image");
return "success";
}
当使用Spring Rest API进行iam测试时,它会引发400个错误请求
MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
map.add("entity", new CustomEntity());
String response = restTemplate.postForObject(SERVER_URI+"/add", map, String.class);
我需要改变什么? [链接](In a Spring controller, can I have a method called based on the number of request parameters?)