To build the ckeditor environment, see the ckeditor3.6 getting started tutorial in JSP.
The JSP page uses the Rich Text control ckeditor to submit form data
Use the Rich Text control ckeditor to customize the style on the JSP page
JSP uses ckeditor and ckfinder to download Rich Text and upload source code
1. Download
Ckeditor is: http://ckeditor.com/download
Ckfinder is: http://ckfinder.com/download
Decompress the ckeditor-java-x.x.zip and ckfinder_java_x.x.zip files you downloaded.
Copy ckfinder_java_x.x \ ckfinder \ _ sources \ ckfinderfor_java \ webapp \ SRC \ main \ webapp \ ckfinder to the webroot directory of your project.
3. Copy all the packages under the lib directory of the two files you downloaded to the lib directory of your project.
4. In the ckfinder_java_x.x directoryCkfinder_java_x.x \ ckfinder \ _ sources \ ckfinderfor Java \ webapp \ SRC \ main \ webapp \ config under the directory of the WEB-INF. copy the XML file to the webroot \ WEB-INF directory of your project, and then config. XML:
Change <enabled> false </enabled> In the first row to <enabled> true </enabled>;
Set<Baseurl>/code/upload/</baseurl>
(Here is the path for storing your uploaded files. Change it to the location you want to store in your root directory)Here I use the absolute path, where code is the name of the project. If this is not the case, the path obtained by uploading the image will be/upload/directory, leading to the failure to display the image normally.
5. modify web. XML in the project
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><servlet><servlet-name>ConnectorServlet</servlet-name><servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class><init-param><param-name>XMLConfig</param-name><param-value>/WEB-INF/config.xml</param-value></init-param><init-param><param-name>debug</param-name><param-value>false</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>ConnectorServlet</servlet-name><url-pattern>/ckfinder/core/connector/java/connector.java</url-pattern></servlet-mapping><session-config><session-timeout>10</session-timeout></session-config><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>
6. Call -- index. jsp on the JSP page by using taglib.
<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" GBK "%> <% @ taglib uri =" http://ckeditor.com "prefix =" ckeditor "%> <% @ taglib uri =" http://ckfinder.com "prefix =" ckfinder "%> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML>
VII. Test
8. Accept the dotest. JSP code and display results on the page
<% @ Page Language = "Java" Import = "Java. util. *" pageencoding = "GBK" %> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML>