后台
@RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public Map<String, Object> upload(String file, HttpServletRequest request, HttpSession session) {
System.out.println(file);
Map<String, Object> map = new HashMap<String, Object>();
return map;
}
加 @RequestParam
直接进不来了
打印 System.out.println(file);
为 null
你这是把文件当String发了?你确定这样能接到?没这样做过
一般Spring传文件,前台改multipart/form-data,后台用MultipartFile接收,这种比较常见吧
按照上传图片处理。你现在是当作字符串,不行的。