Java Web 通过CKEditor实现在线编译器
2016-04-01 22:45
393 查看
1、CKEditor的下载
2、CKEditor的创建
(1)将下载的ckeditor复制到Web工程的WebRoot下
(2)创建jsp页面或者HTML页面,在页面中导入ckeditor.js文件,通过<script type="text/javascript" src="ckeditor/ckeditor.js">
</script>导入,创建textarea元素,将其class属性设置为ckeditor。
3、CKEditor的配置
CKEditor的配置都集中在ckeditor/config.js文件中。
可以在{}中对CKEditor进行配置,常用的参数如下
(1)config.language:界面语言,常见取值'en','zh-cn'。
(2)config.width,config.height:编辑器的宽度和高度,以像素为单位。
(3)config.skin:编译器样式,取值有3个——'kama'(默认)、'office2003'、'v2'。
(4)config。UIColor:编译器背景颜色。
(5)config.toolbar:定义工具栏,有基础'Basic'、全能'Full'、自定义3个取值
案例——使用CKEditor编译器公告内容
1、公告编辑界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<title>Insert title here</title>
</head>
<body>
<center>
<form action="show.jsp" method="post">
编辑公告内容<textarea class="ckeditor" name="newsBody" rows="80" cols="10"></textarea>
<input type="submit" value="显示公告内容">
</form>
</center>
</body>
</html>
2、公告显示界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<%=request.getParameter("newsBody") %>
</body>
</html>
2、CKEditor的创建
(1)将下载的ckeditor复制到Web工程的WebRoot下
(2)创建jsp页面或者HTML页面,在页面中导入ckeditor.js文件,通过<script type="text/javascript" src="ckeditor/ckeditor.js">
</script>导入,创建textarea元素,将其class属性设置为ckeditor。
3、CKEditor的配置
CKEditor的配置都集中在ckeditor/config.js文件中。
可以在{}中对CKEditor进行配置,常用的参数如下
(1)config.language:界面语言,常见取值'en','zh-cn'。
(2)config.width,config.height:编辑器的宽度和高度,以像素为单位。
(3)config.skin:编译器样式,取值有3个——'kama'(默认)、'office2003'、'v2'。
(4)config。UIColor:编译器背景颜色。
(5)config.toolbar:定义工具栏,有基础'Basic'、全能'Full'、自定义3个取值
案例——使用CKEditor编译器公告内容
1、公告编辑界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<title>Insert title here</title>
</head>
<body>
<center>
<form action="show.jsp" method="post">
编辑公告内容<textarea class="ckeditor" name="newsBody" rows="80" cols="10"></textarea>
<input type="submit" value="显示公告内容">
</form>
</center>
</body>
</html>
2、公告显示界面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("UTF-8"); %>
<%=request.getParameter("newsBody") %>
</body>
</html>
相关文章推荐
- Java中对象与引用
- struts2配置基础和常见错误
- Java积累
- Java clone() 浅克隆与深度克隆
- 学习javaEE每一天2016.4.1
- Java编程思想篇
- eclipse下maven项目出现红色感叹号
- Eclipse或MyEclipse没有在java类文件上显示Spring图标的问题
- 深入java多态
- 关于Spring Security的笔记
- springboot-shiro chapter02——springboot webmvc jsp
- JavaSE学习笔记(2016.4.1)
- 27 API-反射(类的加载器,反射的使用,动态代理)&设计模式(装饰设计模式,模版设计模式)&JDK新特性(JDK5,JDK6,JDK7,DK8)
- Struts2中的Action
- Java集合类之栈Stack
- springmvc and maven
- 配置持久化框架diamond简介及高阶应用
- 配置持久化框架diamond简介及高阶应用
- Java集合类之向量Vector
- Spring学习笔记(2)-Spring中bean的生命周期