0

I have this controller file with the following code

@PostMapping(path = "/addDefaultTemplate")
void addDefaultTemplate(@Valid @ModelAttribute AddDefaultTemplate defaultTemplate) throws Exception {
 //Logic
}

And i have this AddDefaultTemplate java file

@Data
public class AddDefaultTemplate {

@NotBlank
String name;

@NotNull
String category;

@NotNull
String type;

@NotNull
MultipartFile[] file; 
}

When i comment the multipartfile configuration in the above class, the url is working fine. If i add the multipartfile in the above class url throws 400 error. Why, what's the reason?

This is the request data. enter image description here

venugopal
  • 263
  • 1
  • 7
  • 14
  • Are you sending any file with field name 'file' with the request? – Alien Jul 03 '18 at 09:26
  • yea i'm sending. I have added the request data too. – venugopal Jul 03 '18 at 09:26
  • 1
    refer this https://stackoverflow.com/questions/46517583/spring-cannot-process-multipart-form-data-post-request-error-400-bad-request – Alien Jul 03 '18 at 09:30
  • @Alien It worked alien thnx. But it is like splitting the request. But there is no other option like combining into a single file like AddDefaultTemplate class and sending? – venugopal Jul 03 '18 at 11:49

0 Answers0