I am developing a spring mvc application and I want to handle the multipart request in my controller. In the request, I pass the MultiPartFile as well, I am currently using @RequestParam to get the paramaeter file, the method looks like
@RequestMapping(method = RequestMethod.POST) public def save( @ModelAttribute @Valid Product product, @RequestParam(value = "image", required = false) MultipartFile file) { ..... }
The above code works well in my service and the file gets to the server. Now I saw that in the case of a file, you must use the @RequestPart annotation instead of @RequestParam . Is there something wrong with using @RequestParam for a file? Or could this lead to any error in the future?
java spring spring-boot spring-mvc multipart
Pranav c balan
source share