I have an issue using Ajax upload with Spring 3 MVC. I understand that I have to configure multipartResolver bean in spring config, which I’ve done. Than I can have controller like this
@RequestMapping(value ="/settingsSim")
@ResponseBody
public Map uploadSimSettings(@RequestParam(value="qqfile", required=true) MultipartFile settings) {
Map<String, Object> ret = new HashMap<String, Object>();
return ret;
}
The problem is that when I actually send the request to the server (actually valums Ajax file upload does this for me), I get an Internal server error response and nothing is shown in the logs. I am really scratching my head now, as I cannot figure out the problem.
When using valums plugin I solved this problem by using
@RequestBodySpring annotation.You could rewrite your code as follows:
Note that the variable
bodywill contain the contents of the uploaded file. Also there is no method declaration in your example which means that your method will be mapped to GET request.P.S. I also had this “no multipart boundary” problem when parsing request with Apache Commons.
HttpServletRequest#getParts()returns just an empty collection.