markdown重写的文章地址: http://blog.youkuaiyun.com/wang_jingj/article/details/54343476
这几天用到了UEDITOR的文件上传功能,但是UEDITOR自带的文件上传功能只能将文件上传到项目根目录.百度搜索也没有很多相关的资料,更关键的是没有相关的源代码.
所以今天把我自己实现的这部分代码上传,希望大家共同进步!
如何使用UEDITOR以及UEDITOR的基本配置在这里不多说了,网上多的很.
本代码基于maven,spring3,spring MVC实现.
下面展示实现的过程.
第一步:
在JSP页面重写UEDITOR的getActionUrl方法
//编辑器资源文件根路径 最好在ueditor.config.js中配置
window.UEDITOR_HOME_URL = "/ueditor/";
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor',{initialFrameHeight: 500,initialFrameWidth:800,maximumWords:3000,elementPathEnabled:false});
//复写UEDITOR的getActionUrl 方法,定义自己的Action
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
UE.Editor.prototype.getActionUrl = function(action) {
if (action == 'uploadimage' || action == 'uploadfile') {
var id = $('#carInfoId&#