java 上传 MultipartFile attach 获取不到信息
attach怎么为空
@RequestMapping(value="/upload", method=RequestMethod.POST, produces="application/json;charset=UTF-8")
@ResponseBody
public String upload(Model model, @RequestParam("attach") MultipartFile attach, HttpServletRequest req, HttpSession session) throws IOException {
System.out.println("Name:"+attach.getName());
System.out.println("ContentType:"+attach.getContentType());
System.out.println("OriginalFilename:"+attach.getOriginalFilename());
System.out.println("Size:"+attach.getSize());
System.out.println("Bytes:"+attach.getBytes());
System.out.println("Class:"+attach.getClass());
System.out.println("InputStream:"+attach.getInputStream());
return null;
}
前面全部是空。空子真异常
搞定,应该这么写:@RequestParam("file") MultipartFile file
小伙看你根骨奇佳,潜力无限,来学PHP伐。