文件上传mvc
Controller @Controller @RequestMapping ( "/file" ) public class UploadController { /** * mvc文件上传 * @param request * @param upload * @return * @throws IOException */ @RequestMapping ( "/upload2" ) public String upload2 ( HttpServletRequest request , MultipartFile upload ) throws IOException { String realPath = request . getSession ( ) . getServletContext ( ) . getRealPath ( "/uploads" ) ; File file = new File ( realPath ) ; if ( ! file . exists ( ) ) { file . mkdirs ( ) ; } //获取文件名 String filename = upload . getOriginalFilename ( ) ; String uuid = UUID . randomUUID ( ) . toString ( ) . replace