---
title: "grails集成ckeditor"
author: "paper"
date: "2010-12-28T18:37:06Z"
tags: ["ASP", "Flash", "Grails", "Groovy", "PHP"]
categories: ["Web前端"]
slug: "grails-ckeditor"
draft: false
lastmod: "2010-12-28T18:37:45Z"
id: 854166
url: "https://paper.iteye.com/blog/854166"
---

创建项目后， install-plugin ckeditor 集成 ckeditor

 

配置：

Config.groovy 加上以下配置：

 

ckeditor {

//    config = "/js/ckconfig.js"

    upload {

        //basedir = "/tmp/storagearea/"

        // baseurl = "/uploads/"

        overwrite = false

        link {

            browser = true

            upload = true

            allowed = \['doc', 'docx', 'flv', 'xls']

            denied = ['html', 'htm', 'php', 'php2', 'php3', 'php4', 'php5',

                    'phtml', 'pwml', 'inc', 'asp', 'aspx', 'ascx', 'jsp',

                     'cfm', 'cfc', 'pl', 'bat', 'exe', 'com', 'dll', 'vbs', 'js', 'reg',

                    'cgi', 'htaccess', 'asis', 'sh', 'shtml', 'shtm', 'phtm']

        }

        image {

            browser = true

            upload = true

            allowed = \['jpg', 'gif', 'jpeg', 'png']

            denied = \[]

        }

        flash {

            browser = true

            upload = true

            allowed = \['swf']

            denied = \[]

        }

        flv {

            browser = true

            upload = true

            allowed = \['flv']

            denied = \[]

        }

 

    }

}

使用案例：

&lt;html&gt;

    &lt;head&gt;

        &lt;title&gt;Welcome to Grails&lt;/title&gt;

        &lt;ckeditor:resources /&gt;

    &lt;/head&gt;

    &lt;body&gt;

              &lt;div&gt;

            ${params.editContent}

            &lt;g:form &gt;

                &lt;ckeditor:config

                    height="300px"

                     width="50%" /&gt;

                &lt;ckeditor:editor name="editContent"&gt;&lt;/ckeditor:editor&gt;

                &lt;g:actionSubmit value=" 提 交 "&gt;&lt;/g:actionSubmit&gt;

          &lt;/g:form&gt;

              &lt;/div&gt;

    &lt;/body&gt;

&lt;/html&gt;

 

会有的问题：

上传的中文文件 ( 图片和 flash 如果是中文的话都会出现乱码问题，具体解决可以参考 [http://hi.baidu.com/vottot/blog/item/fd6465069b99e277020881e2.html](http://hi.baidu.com/vottot/blog/item/fd6465069b99e277020881e2.html) )

 

也可以不处理，但是在上传的时候不能直接使用那个文件，在上传之后重新选择即可。