JSP
<form action="/savFile" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit">
</form>
Controller
@ResponseBody
@RequestMapping("/savFile")
public String savFile(MultipartFile file) throws IOException {
//存放路径
String realPath = "E://";
//获取文件名+后缀
String fileName = file.getOriginalFilename();
//保存文件
file.transferTo(new File(realPath + fileName));
return "OK!";
}
最后
以上就是优秀西牛最近收集整理的关于JSP上传文件,MultipartFile接收并保存本地的全部内容,更多相关JSP上传文件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复