Spring MultipartFile validation and conversion

后端 未结 2 1564
Happy的楠姐
Happy的楠姐 2020-12-04 01:13

I currently have a Spring MVC controller that takes a MultipartFile

@RequestMapping(method = RequestMethod.POST)
public String doUpload(@RequestParam(\"file         


        
2条回答
  •  无人及你
    2020-12-04 01:46

    You need a converter that is able to convert a MultipartFile into MyObjects, but not to convert String[] to MyObjectsContainer. - MyObjectsContainer is nothing more than a wrapper around the list of MyObjects.

    But I really don't know if this converter will work, because MultipartFile is some very special parameter.

    For Validation I strongly recommend JSR 303 Bean Validation annotations at MyObjectsContainer

    Then you can write:

    @RequestMapping(method = RequestMethod.POST)
    public String doUpload(@RequestParam("file") final MyObjectsContainer container) {}
    

提交回复
热议问题