在SpringMVC中使用jquery.uploadify怎么实现一个文件上传功能
在SpringMVC中使用 jquery.uploadify怎么实现一个文件上传功能?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
创新互联是一家专业提供横县企业网站建设,专注与成都网站设计、做网站、成都外贸网站建设公司、成都h5网站建设、小程序制作等业务。10年已为横县众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
项目结构

普通表单上传
@RequestMapping("upload")
public @ResponseBody String upload(@RequestParam MultipartFile file) throws IOException {
String path =request.getSession().getServletContext().getRealPath("upload");
File file=new File(path,file.getOriginalFilename());
file.transferTo(file); //保存文件
return "/success";
} uploadify上传文件
<%@ page contentType="text/html;charset=UTF-8" language="java" %>Index spring mvc 上传文件
接口
@RequestMapping(value = "/upload",method = RequestMethod.POST)
public @ResponseBody String upload(HttpServletRequest request, HttpServletResponse response){
String path =request.getSession().getServletContext().getRealPath("upload");
MultipartHttpServletRequest multipartHttpServletRequest=(MultipartHttpServletRequest)request;
Map map = multipartHttpServletRequest.getFileMap();
System.out.println("path:"+path);
File file=new File(path);
if(!file.exists()){
file.mkdirs();
}
try{
for(Map.Entry entity:map.entrySet()){
MultipartFile multipartFile=entity.getValue();
File ff = new File(path,multipartFile.getOriginalFilename());
multipartFile.transferTo(ff);
}
return "success";
}catch (Exception e){
e.printStackTrace();
return "error";
}
} 
关于在SpringMVC中使用 jquery.uploadify怎么实现一个文件上传功能问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。
网站栏目:在SpringMVC中使用jquery.uploadify怎么实现一个文件上传功能
链接分享:http://www.scyingshan.cn/article/jdphgi.html


咨询
建站咨询
