UMEditor 图片上传配置(jsp) 主要使用jsp中的Uploader.java 和 imageUp.jsp两个文件
首先将imageUp.jsp 文件中Uploader.java
其次在config.js中修改imageUrl 这个参数是imageUp.jsp 所在路径,如果配置不对 上传图片会404
<span style="font-size:14px;"> //图片上传配置区
,imageUrl:URL+"jsp/imageUp.jsp" //图片上传提交地址
,imagePath:basePath //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置
,imageFieldName:"upfile" //图片数据的key,若此处修改,需要在后台对应文件修改对应参数
</span>
imagePath 是取图片时的路径
本人将图片另放一个自定义目录
首先修改imageUp.jsp 中上传路径
默认是upload
<span style="font-size:14px;"> request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
Uploader up = new Uploader(request);
up.setSavePath("upload");
String[] fileType = {".gif" , ".png" , ".jpg" , ".jpeg" , ".bmp"};
up.setAllowFiles(fileType);
up.setMaxSize(10000); //单位KB
up.upload();</span>
修改setSavePath("upload") 中参数即可
同时还需修改Uploader.java 中获取绝对路径的方法
<span style="font-size:14px;">private String getPhysicalPath(String path) {
/*String servletPath = this.request.getServletPath();
String realPath = this.request.getSession().getServletContext()
.getRealPath(servletPath);
return new File(realPath).getParent() +"/" +path;*/
return this.request.getSession().getServletContext().getRealPath("/") + "/" + path;
}</span>
如何修改confif.js 中imagePath 这个参数,改成当前项目根目录即可,如上使用basepath