在Grails中使用FCKEditor

安装插件命令:grails install-plugin fckeditor
一、配置config.groovy:
web.app.context.path=MyGrails
fckeditor {
  upload { 
    basedir = "/uploads/" 
    overwrite = false 
    link { 
      browser = true 
      upload = true//指明文件是否允许上传
      allowed = [] 
      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 = false 
      upload = false 
      allowed = ['swf'] 
      denied = [] 
    } 
    media { 
      browser = false 
      upload = false 
      allowed = ['mpg', 'mpeg', 'avi', 'wmv', 'asf', 'mov'] 
      denied = [] 
    } 
  }
}


二、页面调用
<fckeditor:editor fileBrowser="default" id="content" name='content' width='85%' height="400" value="${fieldValue(bean:mybean, field:'content').decodeHTML()}">
${fieldValue(bean:contentInstance, field:'content').decodeHTML()}
预设值
</fckeditor:editor>  

注:
1.toolbar:设置FCKEditor使用的工具栏,可选值有Default、Basic、Standard、Multimedia;
2.value:FCKEditor的预设值,如果保存的是HTML代码,就需要调用decodeHTML(),将原始的HTML代码进行转换。

三、内容字段扩容
class News
{
      String title
      String content
      Date   time

      static constraints = { 
          title (blank:false) 
          content (blank:false,type:'text') 
      }
} 

注:如果数据库中对应的表还是varchar可手动修改成text


你可能感兴趣的:(fckeditor,Flash,asp,grails,groovy)