问题1 相关配置 (整合Springmvc maven)
下载源码版和jsp版本 (如果需要word转存请下载1.4.2版本 1.4.3版本存在bug无法实现word图片转存)
使用springmvc方式重写controlle
@Controller
@RequestMapping(“/ued”)
public class UEditorController
{
@RequestMapping(value="/config")
public void config(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("application/json");
String rootPath = request.getSession()
.getServletContext().getRealPath("/");
try {
String exec = new ActionEnter(request, rootPath).exec();
PrintWriter writer = response.getWriter();
writer.write(exec);
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
修改config.json位置 我是吧这个文件放到了webapp/conf文件夹下面,这样就需要修改寻找
config.json的源码,找到源码中的ConfigManager类的getConfigPath ()方法修改为
return this.rootPath+ File.separator + “conf”+ File.separator + ConfigManager.configFileName;
然后配置ue的文件上传路径(项目外)
“imageUrlPrefix”: “http://localhost:8080/upload/1/2/3/“, /* 图片访问路径前缀 */
“imagePathFormat”: “../../../upload/image/{yyyy}{mm}{dd}/{time}{rand:6}”, /* 上传保存路径,可以自定义保存路径和文件名格式 */
1/2/3是用来消除虚拟路径的
tomcat中配置
这样图片的路径也就配置完成了。
配置ueditor.config.js中的服务器路径
var URL = "ueditor1_4_3_2-src/";
/**
* 配置项主体。注意,此处所有涉及到路径的配置别遗漏URL变量。
*/
window.UEDITOR_CONFIG = {
//为编辑器实例添加一个路径,这个不能被注释
UEDITOR_HOME_URL: URL
// 服务器统一请求接口路径
, serverUrl: "http://localhost:8080/SuChangAdmin/ued/config.action"
如果你的ue是放在遮罩层中,需要上传图片和word图片转储的层
同样修改
ueditor.config.js
,zIndex : 999999 //编辑器层级的基数,默认是900
这样配置就完成了
页面引入
<script type="text/javascript" src="ueditor1_4_3_2-src/ueditor.config.js"></script>
<script type="text/javascript" src="ueditor1_4_3_2-src/ueditor.all.min.js"></script>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="ueditor1_4_3_2-src/lang/zh-cn/zh-cn.js"></script>
ue框
<script id="editor" type="text/plain" style="width:630px;height:400px;"></script>
ue初始化
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var editor = UE.getEditor('editor',{
//关闭字数统计
wordCount:false,
//关闭elementPath
elementPathEnabled:false,
});
问题2
String类型乱码的问题
如果你用的是utf-8编码
只需要在js中将得到数据进行编码就可以了
var de = UE.getEditor(‘editor’).getContent();//获得的ue中的html页面
var detail =encodeURIComponent(de); //如果不对ue进行重新编码(解决%问题),就会抛出标题的异常
问题3
ue的第一次打开不加载内容,第二次打开加载内容,
原因ue加载内容时ue初始化没有完成所以需要先去判断ue加载成以后再去加载内容
//实例化编辑器
//直接调用UE.getEditor('editor')就能拿到相关的实例,使用ready方法判断实例是否全部加载完成加载完成写入内容
UE.getEditor('editor',{wordCount:false,elementPathEnabled:false,})
.ready(function()
{
UE.getEditor('editor',{wordCount:false,elementPathEnabled:false,})
.setContent(data.detail);
});
以上就是是使用ue时需要的一些问题