I'm developing a spring mvc application and I want to handle multipart request in my controller. In the request I'm passing MultiPartFile
also, currently I'm using @RequestParam
to get the file parameter, the method look like,
@RequestMapping(method = RequestMethod.POST)
public def save(
@ModelAttribute @Valid Product product,
@RequestParam(value = "image", required = false) MultipartFile file) {
.....
}
Above code works well in my service and the file is getting on the server side. Now somewhere I saw that in cases that file need to use @RequestPart
annotation instead of @RequestParam
. Is there anything wrong to use @RequestParam
for file ? Or it may cause any kind of error in future?