今天给大家介绍一款特别好用,兼容性特别好的富文本编译器,Ueditor
1,创建一个web工程,我这里的工程名是MyUeditor
2,在WEBRoot下创建一个文件夹,我这里取名家js,然后把我们下载好的文件,全部复制到js文件夹下(下载地址:http://pan.baidu.com/s/1pLhRYKr)
3,进入到ueditor下的jsp下的lib下把jar添加到我们的工程里
把index.jsp页面修改如下
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
pageContext.setAttribute("basePath", request.getContextPath()+"/") ;
%>
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" charset="utf-8" src="${basePath }js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${basePath }/js/ueditor/ueditor.all.min.js"> </script>
<style type="text/css">
div{
width:100%;
}
</style>
</head>
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
</script>
<body>
<div>
<h1>完整demo</h1>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</div>
</body>
</html>
运行web工程,运行结果如下:
根据我们的需求我们可以制动的屏蔽一些功能,我们只需要来到
index.jsp中的代码是根据,我们下载的editor中的index.html而来的