ckeditor 怎么读取并显示数据库中的数据
使用ckeditor 4.0版本在网站中增加富文本编辑框,如下图:使用jquey的$.post函数已经可以将ckeditor中的值传到后台,但是不清楚怎么从把从数据库中读的值显示在ckeditor控件中。即打开页面的时候,就查询数据库,将数据显示在富文本编辑框中。
现在的代码如下:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
%>
<!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">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery-1.7.js"></script>
<script type="text/javascript">
$(document).ready(function(){
CKEDITOR.replace("editor");
//处理CKEDITOR的值
function CKupdate()
{
for (instance in CKEDITOR.instances)
{
CKEDITOR.instances[instance].updateElement();
}
}
$("#subAjax").click(function () {
CKupdate(); //在提交表单前需要做以上处理
$.post("getProductDesc.do", $("#form1").serialize(), function (data) {
if (data == "success")
{
alert("成功");
}
else
{
alert("失败");
}
});
});
});
</script>
<title>Insert title here</title>
</head>
<body>
<div style="width:960px; margin:0 auto;">
<div style="background:url(<%=path%>/images/backColor-1.png) repeat-x; width:100%; height:30px; border-bottom:1px rgb(228,228,228) solid;">
<div style="margin-left:10px;">
<font style="line-height:30px; font-size:14px; letter-spacing:1px;"><strong>产品属性</strong></font>
</div>
</div>
<div>
</div>
<div style="width:920px; margin-top:20px;">
<form id="form1" method="post" action="getProductDesc.do">
<textarea name="editor" rows="" cols=""></textarea><br/>
<input type="button" value="提交" id="subAjax">
<input type="reset">
</form>
</div>
</div>
</body>
</html>
请教怎么把后台从数据读取的值显示在页面上。
另外:问一下,这个控件如果插入图片的话,一般该怎么处理?是和文本一起插入数据库吗?? 多谢!!! --------------------编程问答-------------------- <textarea name="editor" rows="" cols="">${内容}</textarea><br/>
啊行? --------------------编程问答-------------------- <textarea cols="80" id="content" name="announce" rows="20"><%=显示的值%></textarea> --------------------编程问答-------------------- 楼上的也对,使用的是el表达式 --------------------编程问答-------------------- 在JSP页面中先加入 引用 <%@ taglib prefix="s" uri="/struts-tags" %>
下面这句是输出内容 的,其中ent是action中的个对象变量,content是它的属性。
<s:property value="ent.content" />
通过这样就可以输出ent对象中content属性里面的内容 了。 --------------------编程问答--------------------
我没有用struts框架啊 --------------------编程问答--------------------
++ --------------------编程问答-------------------- 数据显示在富文本编辑框中。 你的做法有问题
把数据放到那里干什么
用个 label 显示出数据库里的数据就行了
你可以见一下你的数据库存储的内容 已经HTML 化了
直接读出来 就是有预定格式的了
--------------------编程问答-------------------- 楼上说的是真理呀,你貌似在做无用功。 --------------------编程问答-------------------- 第57行 <textarea name="editor" rows="" cols=""><%=显示的值%></textarea><br/> --------------------编程问答-------------------- 对于四楼的不想说什么了你tmd做过实验吗
补充:Java , Web 开发