SSH集成Fckeditor

SSH集成Fckeditor
使用Fckeditor的话,如果文本内容过长,可以自己去设计一个分页的方法。我想了一个方法,是另外建立2个表,为一对多关系:文章表——页面表。输入方式是用一个大的表单,里面可以有一个ADD的按钮来自行使用DOM来增加TEXT输入框数目,一个TEXT输入框为一个页。提交之后批量添加到页面表里,一个页面是一条记录。显示的时候按照平时做分页的方法来做。下面先贴上正常使用FCKeditor的方法:

去下载了FCKeditor_2.5.1.zip和FCKeditor-2.3.zip,一个是JAVA版本的文件,一个是FCK原本的文件。摆放的方式大概如下图:


web.xml加入代码:

 <!-- fckeditor -->

  <servlet>

        <servlet-name>Connector</servlet-name>
        <servlet-class>com.fredck.FCKeditor.connector.ConnectorServlet</servlet-class>
        <init-param>
            <param-name>baseDir</param-name>
            <!-- 此为文件浏览路径 -->
            <param-value>/UserFiles/</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
        <servlet-name>SimpleUploader</servlet-name>
        <servlet-class>com.fredck.FCKeditor.uploader.SimpleUploaderServlet</servlet-class>
        <init-param>
            <param-name>baseDir</param-name>
            <!-- 此为文件上传路径,需要在WebRoot 目录下新建 UserFiles 文件夹 -->
            <!-- 根据文件的类型还需要新建相关的文件夹 Image、 Flash -->
            <param-value>/UserFiles/</param-value>
        </init-param>

        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>

            <!-- 此参数为是否开启上传功能 -->
            <param-name>enabled</param-name>
            <param-value>false</param-value>
        </init-param>

        <init-param>
            <param-name>AllowedExtensionsFile</param-name>
            <param-value></param-value>
        </init-param>

        <init-param>
            <!-- 此参数为文件过滤,以下的文件类型都不可以上传 -->
            <param-name>DeniedExtensionsFile</param-name>
            <param-value>php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi</param-value>
        </init-param>

        <init-param>
            <param-name>AllowedExtensionsImage</param-name>
            <param-value>jpg|gif|jpeg|png|bmp</param-value>
        </init-param>

        <init-param>
            <param-name>DeniedExtensionsImage</param-name>
            <param-value></param-value>
        </init-param>

        <init-param>
            <param-name>AllowedExtensionsFlash</param-name>
            <param-value>swf|fla</param-value>
        </init-param>

        <init-param>
            <param-name>DeniedExtensionsFlash</param-name>
            <param-value></param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>  

  <servlet-mapping>
    <servlet-name>Connector</servlet-name>
    <url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>SimpleUploader</servlet-name>
    <url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>
  </servlet-mapping>

输入的jsp文件类似如下:

  <html:form action="/fck" method="post">
    <fck:editor id = "fcktext" basePath = "/new1/FCKeditor/"
    height = "100%"
    skinPath = "/new1/FCKeditor/editor/skins/default/"
    toolbarSet = "Default"
        imageBrowserURL = "/new1/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
        linkBrowserURL = "/new1/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
        flashBrowserURL = "/new1/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
    imageUploadURL = "/new1/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"
       linkUploadURL = "/new1/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"
       flashUploadURL = "/new1/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash" >
    </fck:editor>
    <html:submit/><html:cancel/>
    </html:form>

其中的id是对应于ActionForm与validationv.xml里的property。分别类似如下:

  String strfcktext = fckForm.getString("fcktext");

<form name="fckForm">
        <field property="fcktext" depends="required">
       <arg key="fckForm.fcktext"/>    
       </field>  
   </form>

另外需要注意的是,如果显示找不到页面的错误,应该是form里FCK相关的路径设置不正确。数据库段的字段也需要设置足够大。如果传输过程里出现乱码,可以所有jsp页面加入:<%@ page language="java" contentType="text/html; charset=UTF-8"%>,在web.xml里加入u-f8 filter:

<!-- u-f8 filter -->
  <filter>
  <filter-name>encodingFilter</filter-name>
  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  <init-param>
   <param-name>encoding</param-name>
   <param-value>UTF-8</param-value>
  </init-param>
 </filter>

 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>*.do</url-pattern>
 </filter-mapping>

 <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>

你可能感兴趣的:(SSH集成Fckeditor)