SSH下整合CKEditor+CKFinder问题

阅读更多
[color=darkblue]文章转自:http://sky-yangwang.iteye.com/blog/1489925

当然,我也不知道这篇文章的原始出处了,大概是经过很多人修改,测试过的吧。

[size=small]1,ckeditor:

1),http://ckeditor.com/download

CKEditor for Java ;---3.6.2下载;---ckeditor-java-3.6.2.war使用Tomcat分发包;---得到ckeditor-java-3.6.2文件内容;

2),复制ckeditor文件夹到项目web根路径下;

3),复制ckeditor-java-core-3.5.3.jar类库到项目web-inf下。

2,ckfinder:

1),http://ckfinder.com/download

Java;---2.2.1下载;---ckfinder_java_2.2.1.zip解压;---CKFinderJava.war使用Tomcat分发包;---得到CKFinderJava文件;

2),ckfinder

2),复制ckfinder文件夹到项目web根路径下;

3),复制lib下的类库到项目web-inf下(commons-fileupload-1.2.2.jar和commons-io-2.0.1.jar已有,不用复制)。

3,复制CKFinderJava\WEB-INF\config.xml到项目的web-inf下:

Config.xml配置修改:

true;---开启上传;

/sshWeb/WebsiteBackstage/userfiles/---上传文件存放位置;

上传文件、图片、flash的类型配置(先不动);

4,ckeditor\config.js修改:
CKEDITOR.editorConfig = function( config )

{

// Define changes to default configuration here. For example:

// config.language = 'fr';

// config.uiColor = '#AADC6E';

config.language =  "zh-cn" ; 

config.filebrowserWindowWidth = '1000';  

    config.filebrowserWindowHeight = '700'; 

    

config.filebrowserBrowseUrl =  '/sshWeb/ckfinder/ckfinder.html' ;  

    config.filebrowserImageBrowseUrl =  '/sshWeb/ckfinder/ckfinder.html?type=Images' ;  

    config.filebrowserFlashBrowseUrl =  '/sshWeb/ckfinder/ckfinder.html?type=Flash' ;  

    config.filebrowserUploadUrl =  '/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Files' ;  

    config.filebrowserImageUploadUrl =  '/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Images' ;  

    config.filebrowserFlashUploadUrl =  '/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Flash' ;     

};

参考文章:

http://www.cnblogs.com/yezhenhan/archive/2011/12/10/2282986.html

----------------------------------------------------------------------------------------------------

5,Js写法的页面代码:




  

 



     

      

      

     



6,Web.xml配置:

---struts2与servlet并存解决方法:使用自定义过滤器,将web.xml中添加的ckfinder的servlet过滤内容从struts2过滤中排除;
  

        MyServlet  

       util.ReDispatcherFilter  

          

      includeServlets  

       connector.java  

         

      

    

       MyServlet  

        /*  

     

      

       

        struts2

        org.apache.struts2.dispatcher.FilterDispatcher

   

     

       struts2  

       *.action  

   

    

        struts2

        /*

      

    

    

    

ConnectorServlet

com.ckfinder.connector.ConnectorServlet



XMLConfig

/WEB-INF/config.xml





debug

false



1





ConnectorServlet



/ckfinder/core/connector/java/connector.java







FileUploadFilter

com.ckfinder.connector.FileUploadFilter

                

                    sessionCookieName

                    JSESSIONID

                

                

                    sessionParameterName

                    jsessionid

                





FileUploadFilter



/ckfinder/core/connector/java/connector.java

       





10



    

        index.html



7,自定义过滤器:
import java.io.IOException;

import java.util.ArrayList;

import java.util.Arrays;

import javax.servlet.Filter;

import javax.servlet.FilterChain;

import javax.servlet.FilterConfig;

import javax.servlet.RequestDispatcher;

import javax.servlet.ServletException;

import javax.servlet.ServletRequest;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;

public class ReDispatcherFilter implements Filter {

public void destroy() {

   // TODO Auto-generated method stub

}

public void doFilter(ServletRequest req, ServletResponse resp,

    FilterChain chain) throws IOException, ServletException 

{

  

   HttpServletRequest request = (HttpServletRequest)req;

   String target = request.getRequestURI();

   target = target.lastIndexOf("?")>0   

      ?target.substring(target.lastIndexOf("/")+1,target.lastIndexOf("?")-target.lastIndexOf("/"))

      :target.substring(target.lastIndexOf("/")+1);

  

   System.out.println(target);

   if(this.includes.contains(target))

   {

    RequestDispatcher rdsp = request.getRequestDispatcher(target);

   

    System.out.println("go..............."+rdsp);

    rdsp.forward(req, resp);

   }

   else

    chain.doFilter(req, resp);

}

private ArrayList includes = new ArrayList();

public void init(FilterConfig config) throws ServletException {

  

   this.includes.addAll( Arrays.asList(config.getInitParameter("includeServlets").split(",")));

}

}

参考文章:

ssh&ckfinder&ckeditor struts2与servlet并存解决方法

http://blog.csdn.net/databaseyan/article/details/6914654

http://hi.baidu.com/xsl2007/blog/item/4eb796cf94e35f0992457e11.html

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

其它问题:

上传文件中文名问题;

上传文件位置问题;

单纯Ckeditor的使用:

下载最新的ckeditor文件: http://ckeditor.com/download

解压后复制到web层根目录下;

页面引用js:


替换TEXTAREA标签:


你可能感兴趣的:(struts,ckEditor,ckfiner,struts2)