I'm trying to construct method for uploading file with some other form fields.
This is standard Html form with file and some other fields:
<form action="products" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="text" name="name">
<input type="text" name="email">
<input type="submit" value="Upload" name="submit">
</form>
Please note: I want to use standard HTML form, not Spring form tags like <form:form ...>
etc
And this is my controller method:
@ResponseBody
public MyDto createProduct(@RequestBody MyDto dto, @RequestParam MultipartFile file) {
}
But I'm getting error: Required request body content is missing
.
How should I construct my web method to receive file as well as DTO object as arguments? Also it will be nice if I can have MultipartFile object included into MyDto
.