2 lr393993507 lr393993507 于 2013.08.01 20:57 提问

easyui+ckeditor怎么把easyui从数据库提取得数据在ckeditor里显示
 <%@ 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>新闻信息管理</title>
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    var url;

    function deleteNews(){
        var selectedRows=$("#dg").datagrid('getSelections');
        if(selectedRows.length==0){
            $.messager.alert("系统提示","请选择要删除的数据!");
            return;
        }
        var strIds=[];
        for(var i=0;i<selectedRows.length;i++){
            strIds.push(selectedRows[i].newsId);
        }
        var ids=strIds.join(",");
        $.messager.confirm("系统提示","您确认要删掉这<font color=red>"+selectedRows.length+"</font>条数据吗?",function(r){
            if(r){
                $.post("newsDelete",{delIds:ids},function(result){
                    if(result.success){
                        $.messager.alert("系统提示","您已成功删除<font color=red>"+result.delNums+"</font>条数据!");
                        $("#dg").datagrid("reload");
                    }else{
                        $.messager.alert('系统提示',result.errorMsg);
                    }
                },"json");
            }
        });
    }

    function searchNews(){

        $('#dg').datagrid('load',{
            newsTitle:$('#s_newsTitle').val(),
            newsContent:$('#s_newsContent').val(),
            newsAuthor:$('#s_newsAuthor').val(),
            newsTime:$('#s_newsTime').datebox("getValue"),
            newsSources:$('#s_newsSources').val()
        });
        $("#s_newsTime").datebox("setValue","");
    }


    function openNewsAddDialog(){
        $("#dlg").dialog("open").dialog("setTitle","添加新闻信息");
        url="newsSave";
    }

    function saveNews(){
        $("#fm").form("submit",{
            url:url,
            success:function(result){
                if(result.errorMsg){
                    $.messager.alert("系统提示",result.errorMsg);
                    return;
                }else{
                    $.messager.alert("系统提示","保存成功");
                    resetValue();
                    $("#dlg").dialog("close");
                    $("#dg").datagrid("reload");
                }
            }
        });
    }

    function resetValue(){
        $("#newsTitle").val("");
        $("#newsContent").val("");
        $("#newsAuthor").val("");
        $("#newsTime").datebox("setValue","");
        $("#newSources").val("");
    }

    function closeNewsDialog(){
        $("#dlg").dialog("close");
        resetValue();
    }

    function openNewsModifyDialog(){
        var selectedRows=$("#dg").datagrid('getSelections');
        if(selectedRows.length!=1){
            $.messager.alert("系统提示","请选择一条要编辑的数据!");
            return;
        }
        var row=selectedRows[0];
        $("#dlg").dialog("open").dialog("setTitle","编辑新闻信息");
        $("#fm").form("load",row);
        url="newsSave?newsId="+row.newsId;
    }
</script>
</head>
<body style="margin: 5px;">
    <table id="dg" title="新闻信息" class="easyui-datagrid" fitColumns="true"
     pagination="true" rownumbers="true" url="newsList" fit="true" toolbar="#tb">
        <thead>
            <tr>
                <th field="cb" checkbox="true"></th>
                <th field="newsId" width="20" align="center">编号</th>
                <th field="newsTitle" width="100" align="center">新闻标题</th>
                <th field="newsContent" width="300" align="center">新闻内容</th>
                <th field="newsAuthor" width="50" align="center">新闻作者</th>
                <th field="newsTime" width="50" align="center">新闻发布时间</th>
                <th field="newsSources" width="50" align="center">新闻来源</th>
            </tr>
        </thead>
    </table>

    <div id="tb">
        <div>
            <a href="javascript:openNewsAddDialog()" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
            <a href="javascript:openNewsModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
            <a href="javascript:deleteNews()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
        </div>
        <div>&nbsp;新闻标题:&nbsp;<input type="text" name="s_newsTitle" id="s_newsTitle" size="10"/>
        &nbsp;新闻内容:&nbsp;<input type="text" name="s_newsContent" id="s_newsContent" size="10"/>
        &nbsp;新闻作者:&nbsp;<input type="text" name="s_newsAuthor" id="s_newsAuthor" size="10"/>
        &nbsp;新闻时间:&nbsp;<input class="easyui-datebox" name="s_newsTime" id="s_newsTime" editable="false" size="10"/>
        &nbsp;新闻来源:&nbsp;<input type="text" name="s_newsSources" id="s_newsSources" size="10"/>

        <a href="javascript:searchNews()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a></div>
    </div>

    <div id="dlg" class="easyui-dialog" style="width: 1050px;height: 500px;padding: 20px 20px"
        closed="true" buttons="#dlg-buttons">
        <form id="fm" method="post">
            <table cellspacing="5px;">
                <tr>
                    <td>新闻标题:</td>
                    <td><input type="text" name="newsTitle" id="newsTitle" class="easyui-validatebox" required="true" size="60"/></td>
                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                    <td>新闻来源:</td>
                    <td><input type="text" name="newsSources" id="newsSources" class="easyui-validatebox" required="true" size="60"/></td>
                    <td></td>
                </tr>
                <tr>
                    <td>新闻作者:</td>
                    <td><input type="text" name="newsAuthor" id="newsAuthor" class="easyui-validatebox" required="true" size="60"/></td>
                    <td></td>
                    <td>新闻时间:</td>
                    <td><input class="easyui-datebox" name="newsTime" id="newsTime" required="true" editable="false" size="60" /></td>
                </tr>
                <tr>
                    <td>新闻内容:</td>
                    <td colspan="4"><textarea class="ckeditor" rows="7" cols="50" name="newsContent" id="newsContent"></textarea></td>
                    <td></td>
                </tr>
            </table>
        </form>
    </div>

    <div id="dlg-buttons">
        <a href="javascript:saveNews()" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
        <a href="javascript:closeNewsDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
    </div>
</body>
</html>

我要用ckeditor对数据库里的内容进行编辑!求各位大神给方法 或者思路,我用的是jsp+servlet

2个回答

xiangshiming1992
xiangshiming1992   2015.02.27 14:18

风格的广泛的

qq_17786039
qq_17786039   2015.04.14 09:59

通过绑定数据来得到,easyui本来有个field的属性,在加载的时候会自动加载,所以你需要把field的属性加到源码中

Csdn user default icon
上传中...
上传图片
插入图片