Skip to content

Instantly share code, notes, and snippets.

@jpukg
Forked from wangyangcx/UploadController.java
Created October 10, 2016 18:45
Show Gist options
  • Select an option

  • Save jpukg/5eb559e4694893da730d611cfabf9622 to your computer and use it in GitHub Desktop.

Select an option

Save jpukg/5eb559e4694893da730d611cfabf9622 to your computer and use it in GitHub Desktop.
extjs file upload & spring mvc
@RequestMapping(value = "/upload", method = RequestMethod.POST, produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public String upload(@RequestParam("file") MultipartFile file, String name, String message) throws Exception
{
Map<String, Object> resp = Maps.newHashMap();
FileCopyUtils.copy(file.getBytes(), new File('filename'));
resp.put("success", true);
resp.put("msg", "upload success.");
return JSONObject.toJSONString(resp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment