spring mvc 上传文件
来源:互联网 发布:apt模型 知乎 编辑:程序博客网 时间:2024/05/22 11:55
@RequestMapping("/bid/post")
public String bidList(ProjectPost projectPost, Model model,
@RequestParam CommonsMultipartFile bidFile,
HttpServletRequest request) throws Exception {
Member sessionUser = getSessionUser(request);
long enterpriseId = sessionUser.getEnterprise().getId();
long projectId = sessionUser.getProjectProfileId();
projectPost.setEnterpriseId(enterpriseId);
ProjectDoc projectDoc = new ProjectDoc();
if (bidFile != null) {
if (!bidFile.getOriginalFilename().equals("")) {
// String uploadPath =
// request.getServletContext().getRealPath("")+ File.separator +
// UPLOAD_DIRECTORY;
String uploadPath = request.getContextPath() + File.separator
+ UPLOAD_DIRECTORY;
String filePath = uploadPath + File.separator + projectId + "_"
+ bidFile.getOriginalFilename();
filePath = filePath.replaceFirst("/", "");
System.out.println("ProjectPost save bid file path is:"
+ filePath);
uploadPath = "D:\\Workspaces\\" + uploadPath;
uploadPath = uploadPath.replaceFirst("/", "");
String uploadRealPath = "D:\\Workspaces\\" + filePath;
System.out.println("ProjectPost save bid file path is:"
+ uploadRealPath);
// 查看目录是否存在
File uploadDir = new File(uploadPath);
if (!uploadDir.exists()) {
uploadDir.mkdir();
}
bidFile.transferTo(new File(uploadRealPath));
System.out.println("Saving file: "
+ bidFile.getOriginalFilename());
0 0
- spring mvc 文件上传
- spring MVC 文件上传
- Spring MVC文件上传
- Spring MVC文件上传
- spring mvc 文件上传
- Spring mvc 文件上传
- spring mvc 文件上传
- spring mvc 上传文件
- spring mvc 上传文件
- spring mvc 文件上传
- spring mvc 上传文件
- spring mvc文件上传
- Spring MVC 文件上传
- spring mvc 文件上传
- spring mvc文件上传
- Spring MVC文件上传
- spring mvc 文件上传
- spring mvc 上传文件
- WEB 端批量移动设备管理控制工具 STF 的环境搭建和运行
- SAP之成本中心类型与功能范围
- CC2530定时器3通道1输入捕获中断
- Chrome浏览器V43版本不支持silverlight 5.0的解决办法
- Java排序算法实现
- spring mvc 上传文件
- 代码如人
- IOS TableView 根据子view 来获取当前Cell 方式
- MongoDB MapReduce(转)
- NSIS (NullSoft Scriptable Install System)使用指北(超详细)
- js dojo 保存txt文件
- HDU 4528 小明系列故事――捉迷藏 (很好的BFS)
- 使用脚本进行ssh登录服务器(Linux新手之路)
- 增值构造法子集生成