红联Linux门户
Linux帮助

Rose上传下载

发布时间:2013-06-14 17:26:01来源:红联作者:
[code]//-------前端VM







//-------后台Controller
@Post("uploadFile")
public String uploadFile(Invocation inv, @Param("file") MultipartFile file) {
String path = "D:/workSpace/tomcat6/webapps/RoseBook/upload";
try {
FileOutputStream fos = new FileOutputStream(new File(path, file.getOriginalFilename()));
byte b[] = new byte[(int) file.getBytes().length];
file.getInputStream().read(b);
fos.write(b);
fos.close();
inv.addModel("uploadFileName", file.getOriginalFilename());// 上次信息文件名
inv.addModel("length", file.getBytes().length);// 上次文件大小
inv.addModel("path", path);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return "success";
}[/code]现在我 后台中的 path(文件路径给的是死的) 我怎么能的到 服务器的路径.? 求指点.... 还有Rose 中的 下载该如何实现???
文章评论

共有 1 条评论

  1. slhappylife 于 2013-06-15 04:25:18发表:

    牛人呀.