首先打開網站:http://sourceforge.net/projects/fckeditor/files/FCKeditor.Java/2.6/
分別下載:fckeditor-java-2.6-bin.zip、FCKeditor_2.6.8.zip
一、FCK配置
1、解壓fckeditor-java-2.6-bin.zip後,將其lib下的jar包拷貝至工程的lib中;
2、FCKeditor_2.6.8.zip解壓後,將fckeditor文件夾整個拷貝至WebRoot下。
3、配置web.xml
二、FCK添加、修改、顯示在jsp中
1、add.jsp
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<script type="text/javascript" src="<%=path %>/fckeditor/fckeditor.js"></script>
在需要使用編輯器的地方加以下代碼
<FCK:editor instanceName="contentTxt.txt" height="200" value=" " />
注意:此處保持value等於空,否則會拋空指針異常
2、update.jsp
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<%@page import="net.cnki.tpi.cms.model.ContentTxt" %>
<script type="text/javascript" src="<%=path %>/fckeditor/fckeditor.js"></script>
注意:可能因爲FCK標籤中,不支持直接用struts2來取值,只能先將值取出,然後再顯示。如下:
<%
String txt=" ";
String txt1=" ";
String txt2=" ";
String txt3=" ";
ContentTxt contentTxt = (ContentTxt)request.getAttribute("contentTxt");
txt = contentTxt.getTxt();
txt1 = contentTxt.getTxt1();
txt2 = contentTxt.getTxt2();
txt3 = contentTxt.getTxt3();
%>
在需要使用編輯器的地方加以下代碼
<FCK:editor instanceName="contentTxt.txt" height="200" value="<%=txt%>" />
3、show.jsp
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<%@page import="net.cnki.tpi.cms.model.ContentTxt" %>
<script type="text/javascript" src="<%=path %>/fckeditor/fckeditor.js"></script>
注意:可能因爲FCK標籤中,不支持直接用struts2來取值,只能先將值取出,然後再顯示。如下:
<%
String txt=" ";
String txt1=" ";
String txt2=" ";
String txt3=" ";
ContentTxt contentTxt = (ContentTxt)request.getAttribute("contentTxt");
txt = contentTxt.getTxt();
txt1 = contentTxt.getTxt1();
txt2 = contentTxt.getTxt2();
txt3 = contentTxt.getTxt3();
%>
在需要顯示的地方加以下代碼
<%=txt%>
<%=txt2%>