首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

SSH下整合CKEditor+CKFinder有关问题

2013-08-04 
SSH下整合CKEditor+CKFinder问题转自:http://hunanpengdake.iteye.com/blog/1633814SSH下整合CKEditor+CKF

SSH下整合CKEditor+CKFinder问题

转自:http://hunanpengdake.iteye.com/blog/1633814

SSH下整合CKEditor+CKFinder问题博客分类:
    ?常用后台框架Js代码??SSH下整合CKEditor+CKFinder有关问题
    1. CKEDITOR.editorConfig?=?function(?config?)??
    2. ??
    3. {??
    4. ??
    5. //?Define?changes?to?default?configuration?here.?For?example:??
    6. ??
    7. //?config.language?=?'fr';??
    8. ??
    9. //?config.uiColor?=?'#AADC6E';??
    10. ??
    11. config.language?=??"zh-cn"?;???
    12. ??
    13. config.filebrowserWindowWidth?=?'1000';????
    14. ??
    15. ????config.filebrowserWindowHeight?=?'700';???
    16. ??
    17. ??????
    18. ??
    19. config.filebrowserBrowseUrl?=??'/sshWeb/ckfinder/ckfinder.html'?;????
    20. ??
    21. ????config.filebrowserImageBrowseUrl?=??'/sshWeb/ckfinder/ckfinder.html?type=Images'?;????
    22. ??
    23. ????config.filebrowserFlashBrowseUrl?=??'/sshWeb/ckfinder/ckfinder.html?type=Flash'?;????
    24. ??
    25. ????config.filebrowserUploadUrl?=??'/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Files'?;????
    26. ??
    27. ????config.filebrowserImageUploadUrl?=??'/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Images'?;????
    28. ??
    29. ????config.filebrowserFlashUploadUrl?=??'/ckfinder/core/connector/java/connector.java?command=QuickUpload&type=Flash'?;???????
    30. ??
    31. };??

    参考文章:?

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

    ----------------------------------------------------------------?

    5,Js写法的页面代码:?
    Html代码??SSH下整合CKEditor+CKFinder有关问题
    1. <script?src="../../ckeditor/ckeditor.js"?type="text/javascript"></script>??
    2. ??
    3. <script?src="../../ckfinder/ckfinder.js"?type="text/javascript"></script>??
    4. ??
    5. <script?src="../js/jquery-1.7.2.js"?type="text/javascript"></script>????
    6. ??
    7. <script?src="../../ckeditor/adapters/jquery.js"?type="text/javascript"></script>???
    8. ??
    9. <s:form?action="about_add">??
    10. ??
    11. ?????<s:textfield?name="aboutUs.title"?label="标题"/>??
    12. ??
    13. ??????<s:textarea?name="aboutUs.content"?rows="30"?cols="50"?label="内容"/>??
    14. ??
    15. ??????<script?type="text/javascript">????
    16. ??
    17. ?????????????????$('#editor').ckeditor();????
    18. ??
    19. ?????????????????var?editor?=?CKEDITOR.replace('aboutUs.content');??
    20. ??
    21. ?????????????????CKFinder.setupCKEditor(editor,?'/sshWeb/ckfinder/');??
    22. ??
    23. ????????????</script>??
    24. ??
    25. ?????<s:submit/>??
    26. ??
    27. </s:form>??

    6,Web.xml配置:?

    ---struts2与servlet并存解决方法:使用自定义过滤器,将web.xml中添加的ckfinder的servlet过滤内容从struts2过滤中排除;?
    Xml代码??SSH下整合CKEditor+CKFinder有关问题
    1. <filter>????
    2. ??
    3. ????????<filter-name>MyServlet</filter-name>????
    4. ??
    5. ???????<filter-class>util.ReDispatcherFilter</filter-class>????
    6. ??
    7. ????????<init-param>????
    8. ??
    9. ??????<param-name>includeServlets</param-name>????
    10. ??
    11. ???????<param-value>connector.java</param-value>????
    12. ??
    13. ???????</init-param>????
    14. ??
    15. ????</filter>????
    16. ??
    17. ??<filter-mapping>????
    18. ??
    19. ???????<filter-name>MyServlet</filter-name>????
    20. ??
    21. ????????<url-pattern>/*</url-pattern>????
    22. ??
    23. ???</filter-mapping>????
    24. ??
    25. ????????
    26. ??
    27. ???????<filter>??
    28. ??
    29. ????????<filter-name>struts2</filter-name>??
    30. ??
    31. ????????<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>??
    32. ??
    33. ???</filter>??
    34. ??
    35. ???<filter-mapping>????
    36. ??
    37. ???????<filter-name>struts2</filter-name>????
    38. ??
    39. ???????<url-pattern>*.action</url-pattern>????
    40. ??
    41. ???</filter-mapping>??
    42. ??
    43. ????<filter-mapping>??
    44. ??
    45. ????????<filter-name>struts2</filter-name>??
    46. ??
    47. ????????<url-pattern>/*</url-pattern>??
    48. ??
    49. ????</filter-mapping>????
    50. ??
    51. ??????
    52. ??
    53. ??????
    54. ??
    55. ????<servlet>??
    56. ??
    57. <servlet-name>ConnectorServlet</servlet-name>??
    58. ??
    59. <servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class>??
    60. ??
    61. <init-param>??
    62. ??
    63. <param-name>XMLConfig</param-name>??
    64. ??
    65. <param-value>/WEB-INF/config.xml</param-value>??
    66. ??
    67. </init-param>??
    68. ??
    69. <init-param>??
    70. ??
    71. <param-name>debug</param-name>??
    72. ??
    73. <param-value>false</param-value>??
    74. ??
    75. </init-param>??
    76. ??
    77. <load-on-startup>1</load-on-startup>??
    78. ??
    79. </servlet>??
    80. ??
    81. <servlet-mapping>??
    82. ??
    83. <servlet-name>ConnectorServlet</servlet-name>??
    84. ??
    85. <url-pattern>??
    86. ??
    87. /ckfinder/core/connector/java/connector.java??
    88. ??
    89. </url-pattern>??
    90. ??
    91. </servlet-mapping>??
    92. ??
    93. <filter>??
    94. ??
    95. <filter-name>FileUploadFilter</filter-name>??
    96. ??
    97. <filter-class>com.ckfinder.connector.FileUploadFilter</filter-class>??
    98. ??
    99. ????????????????<init-param>??
    100. ??
    101. ????????????????????<param-name>sessionCookieName</param-name>??
    102. ??
    103. ????????????????????<param-value>JSESSIONID</param-value>??
    104. ??
    105. ????????????????</init-param>??
    106. ??
    107. ????????????????<init-param>??
    108. ??
    109. ????????????????????<param-name>sessionParameterName</param-name>??
    110. ??
    111. ????????????????????<param-value>jsessionid</param-value>??
    112. ??
    113. ????????????????</init-param>??
    114. ??
    115. </filter>??
    116. ??
    117. <filter-mapping>??
    118. ??
    119. <filter-name>FileUploadFilter</filter-name>??
    120. ??
    121. <url-pattern>??
    122. ??
    123. /ckfinder/core/connector/java/connector.java??
    124. ??
    125. ???????</url-pattern>??
    126. ??
    127. </filter-mapping>??
    128. ??
    129. <session-config>??
    130. ??
    131. <session-timeout>10</session-timeout>??
    132. ??
    133. </session-config>??
    134. ??
    135. ????<welcome-file-list>??
    136. ??
    137. ????????<welcome-file>index.html</welcome-file>??
    138. ??
    139. </welcome-file-list>??

    7,自定义过滤器:?
    Java代码??SSH下整合CKEditor+CKFinder有关问题
    1. import?java.io.IOException;??
    2. ??
    3. import?java.util.ArrayList;??
    4. ??
    5. import?java.util.Arrays;??
    6. ??
    7. import?javax.servlet.Filter;??
    8. ??
    9. import?javax.servlet.FilterChain;??
    10. ??
    11. import?javax.servlet.FilterConfig;??
    12. ??
    13. import?javax.servlet.RequestDispatcher;??
    14. ??
    15. import?javax.servlet.ServletException;??
    16. ??
    17. import?javax.servlet.ServletRequest;??
    18. ??
    19. import?javax.servlet.ServletResponse;??
    20. ??
    21. import?javax.servlet.http.HttpServletRequest;??
    22. ??
    23. public?class?ReDispatcherFilter?implements?Filter?{??
    24. ??
    25. public?void?destroy()?{??
    26. ??
    27. ???//?TODO?Auto-generated?method?stub??
    28. ??
    29. }??
    30. ??
    31. public?void?doFilter(ServletRequest?req,?ServletResponse?resp,??
    32. ??
    33. ????FilterChain?chain)?throws?IOException,?ServletException???
    34. ??
    35. {??
    36. ??
    37. ????
    38. ??
    39. ???HttpServletRequest?request?=?(HttpServletRequest)req;??
    40. ??
    41. ???String?target?=?request.getRequestURI();??
    42. ??
    43. ???target?=?target.lastIndexOf("?")>0?????
    44. ??
    45. ???????target.substring(target.lastIndexOf("/")+1,target.lastIndexOf("?")-target.lastIndexOf("/"))??
    46. ??
    47. ??????:target.substring(target.lastIndexOf("/")+1);??
    48. ??
    49. ????
    50. ??
    51. ???System.out.println(target);??
    52. ??
    53. ???if(this.includes.contains(target))??
    54. ??
    55. ???{??
    56. ??
    57. ????RequestDispatcher?rdsp?=?request.getRequestDispatcher(target);??
    58. ??
    59. ?????
    60. ??
    61. ????System.out.println("go..............."+rdsp);??
    62. ??
    63. ????rdsp.forward(req,?resp);??
    64. ??
    65. ???}??
    66. ??
    67. ???else??
    68. ??
    69. ????chain.doFilter(req,?resp);??
    70. ??
    71. }??
    72. ??
    73. private?ArrayList<String>?includes?=?new?ArrayList<String>();??
    74. ??
    75. public?void?init(FilterConfig?config)?throws?ServletException?{??
    76. ??
    77. ????
    78. ??
    79. ???this.includes.addAll(?Arrays.asList(config.getInitParameter("includeServlets").split(",")));??
    80. ??
    81. }??
    82. ??
    83. }??

    参考文章:?

    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:?
    Html代码??SSH下整合CKEditor+CKFinder有关问题
    1. <script?src="ckeditor/ckeditor.js"?type="text/javascript"></script>??

    替换TEXTAREA标签:?
    Html代码??SSH下整合CKEditor+CKFinder有关问题
    1. <textarea?rows="30"?cols="50"?name="editor01">请输入.</textarea>??
    2. <script?type="text/javascript">CKEDITOR.replace('editor01');</script>??

热点排行