SpringMVC Ueditor1.4.3 未找到上传数据
} catch (FileUploadException e) {
return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
} catch (IOException e) {
}
return new BaseState(false, AppInfo.IO_ERROR);
}*/
public static final State save(HttpServletRequest request,
Map<String, Object> conf) {
try {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile multipartFile = multipartRequest.getFile(conf.get("fieldName").toString());
String savePath = (String) conf.get("savePath");
String originFileName = multipartFile.getOriginalFilename();
String suffix = FileType.getSuffixByFilename(originFileName);
originFileName = originFileName.substring(0,originFileName.length() - suffix.length());
savePath = savePath + suffix;
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
/***********/
//自定义
savePath = PathFormat.parse(savePath, originFileName);
String [] savePathBySplit_temp = savePath.split("/");
String temp = "";
String fileName = savePathBySplit_temp[savePathBySplit_temp.length-1];
for(int i = 2;i < savePathBySplit_temp.length-1; i++){
if(i!=savePathBySplit_temp.length-2){
temp+=savePathBySplit_temp[i]+"/";
}else{
temp+=savePathBySplit_temp[i];
}
}
String pathTemp = request.getSession().getServletContext().getRealPath(temp);
System.out.println(pathTemp+","+fileName);
System.out.println(new File(pathTemp).exists());
File targetFile = new File(pathTemp);
if(!targetFile.exists()){
targetFile.mkdirs();
}
System.out.println(new File(pathTemp).exists());
/************/
//State storageState = StorageManager.saveFileByInputStream(multipartFile.getInputStream(),savePath, maxSize);
State storageState = StorageManager.saveFileByInputStream(multipartFile.getInputStream(),pathTemp+"/"+fileName, maxSize);
if (storageState.isSuccess()) {
storageState.putInfo("url", PathFormat.format(savePath));
storageState.putInfo("type", suffix);
storageState.putInfo("original", originFileName + suffix);
}
return storageState;
}catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
return new BaseState(false, AppInfo.IO_ERROR);
}
SpringMVC Ueditor1.4.3 未找到上传数据的更多相关文章
- ueditor富文本上传图片的时候报错"未找上传数据"
最近因为需求所以在ssh项目中使用了Ueditor富文本插件,但是在上传图片的时候总是提示“未找到上传数据”,之后百度了好久终于弄明白了.因为Ueditor在上传图片的时候会访问controller. ...
- ueditor1.3.6jsp版在struts2应用中上传图片报"未找到上传文件"解决方案
摘要: ueditor1.3.6jsp版在struts2应用中上传图片报"未找到上传文件"解决方案 在struts2应用中使用ueditor富文本编辑器上传图片或者附件时,即使配置 ...
- ueditor1.4.3jsp版在上传图片报"未找到上传文件"解决方案
这是因为struts2的过滤器,解决方法是自定义一个过滤器 新建一个过滤器的类,代码: package com.filter; import java.io.IOException; import j ...
- 关于ueditor 在struts2 中 上传图片 ,未找到上传文件 问题的解决方法
问题原因: ueditor 上传图片需请求imageUp.jsp文件,struts2 自带的拦截器(/*)把所有请求的文件都做了处理,所以导致无法上传图片. 解决方法: 方法一:自定义拦截器,让它在请 ...
- SpringMVC结合ajaxfileupload文件无刷新上传
jQuery没有提供ajax的文件上传,我们可以通过ajaxfileupload实现ajax文件的上传.其实ajaxfileupload文件上传特别的简单.下面就演示一下在SpringMVC中实现aj ...
- spring--mvc添加用户及用户头像上传
spring--mvc添加用户及用户头像上传 添加用户步骤: 1.用ajax获取省份信息 2.添加用户 代码:register.jsp <meta http-equiv="Conten ...
- SpringMVC(四)-- springmvc的系统学习之文件上传、ajax&json处理
资源:尚学堂 邹波 springmvc框架视频 一.文件上传 1.步骤: (1)导入jar包 commons-fileupload,commons-io (2)在springmvc的配置文件中配置解析 ...
- 分享知识-快乐自己:SpringMvc中的单多文件上传及文件下载
摘要:SpringMvc中的单多文件上传及文件下载:(以下是核心代码(拿过去直接能用)不谢) <!--设置文件上传需要的jar--> <dependency> <grou ...
- TortoiseGit和msysGit安装及使用笔记(windows下使用上传数据到GitHub)[转]
TortoiseGit和msysGit安装及使用笔记(windows下使用上传数据到GitHub) Git-1.7.11-preview+GitExtensions244SetupComplete+T ...
随机推荐
- UVALive 2238 Fixed Partition Memory Management 固定分区内存管理(KM算法,变形)
题意:目前有一部分可用内存,分为m个大小固定的区域.现有n个程序要执行,每个程序在不同大小的内存中运行所需的时间不同,要使运行完所有程序所耗时最少,问每个程序在哪块区域中从什么时间运行到什么时间,以及 ...
- LibreOJ #109. 并查集
题目描述 这是一道模板题. 维护一个 nnn 点的无向图,支持: 加入一条连接 uuu 和 vvv 的无向边 查询 uuu 和 vvv 的连通性 由于本题数据较大,因此输出的时候采用特殊的输出方式:用 ...
- 使用ABAP正则表达式解析HTML标签
需求就是我用ABAP的某个函数从数据库读取一个字符串出来,该字符串的内容是一个网页. 网页的form里包含了很多隐藏的input field.我的任务是解析出name为svyValueGuid的inp ...
- DoveCLL and Resistance(湖北省赛)
题目 构造一个由串联和并联构成的纯电阻电路,使得该电路的等效电阻为p/q,其中(p,q) = 1.要求输出n,表示节点数,m表示电阻个数,m行每行ui,vi,wi,表示ui和vi之间要连上一个电阻为w ...
- ref版的 摄像头 读取 因为id的时候,id不能重复 还要用时间戳,比较麻烦
<!-- * @description 摄像头vue版实例 * @fileName cameraObject.vue * @author 彭成刚 * @date // :: * @version ...
- vue-gemini-scrollbar(vue组件-自定义滚动条)
vue-gemini-scrollbar(vue组件-自定义滚动条) https://segmentfault.com/a/1190000013338560
- postman使用--批量执行测试用例和数据驱动
批量执行 在我们测试接口的时候,有时候希望执行所有的测试用例,前面讲的都是测试单个的接口,postman提供了我们批量执行接口的功能 点击Runner 然后我们点击run 执行完会统计出我们的结果,失 ...
- JSON parse error: Can not construct instance of model.Class: no suitable constructor found
reference:http://blog.csdn.net/qq_33642117/article/details/51909346 当类中没有定义构造函数时,系统会指定给该类加上一个空参数的构造函 ...
- 2018美赛准备之路——Matlab基础——命令行功能函数
clc 清屏(只清除显示内容) clear 清除所有变量(运算结果) who 显示workspace的所有变量 whos 详细显示workspace的所有变量 help sin 显示sin函数 ...
- 常见的linux命令及其翻译
常见的linux指令 1.ls ll 查看文件信息 2.cd 切换工作目录 cd 或 cd ~ 切换到/home/用户目录 cd. 切换到当前目录 cd.. 切换到上级目录 cd- 切换入上次所在的目 ...