浏览 1767 次
锁定老帖子 主题:FCKEditor的使用
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-05-17
下面是我在内容管理系统中使用的Fckeditor的代码片段,代码比较简单,可供没接触过FCKEditor的初学者参考。
JSP: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck"%> <%@ page import="java.util.*" %> <%@ page import="org.zcinfomanage.common.ZCStaticData" %> <%@ page import="org.zcinfomanage.column.dao.SiteColumnDAOImpl" %> <%@ page import="org.zcinfomanage.pagemanage.po.SiteColumn" %> <%String appContext = request.getContextPath(); %> <html> <head><title>Test</title> <script type="text/javascript"> function GetInnerHTML(){ // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('testfck'); alert( oEditor.EditorDocument.body.innerHTML ) ; } </script> </head> <link href="css.css" rel="stylesheet" type="text/css" /> <body> <FORM name="webPageForm" action="<%=appContext %>/webPageManage.do?method=addWebPage" method="post"> <table width="97%" border="0" cellspacing="1" cellpadding="2" class="borde2"> <tr> <td height="40" background="UserFiles/Image/bg_table.jpg" bgcolor="#CBE9F9" class="jianju5 jianju4 fontBlueno"> <html:messages id="message" message="true"> <font color="#ff0000"> <LI> <bean:write name="message"/> </LI> </font> </html:messages> </td> </tr> </table> <table width="97%" cellpadding="2" cellspacing="1"> <tr> <td height="40" bgcolor="#FFFFCC" class="w"> 栏目名称: <select name="siteColumnID"> <OPTION value="0" >请选择栏目</OPTION> <% List siteColumnList = ZCStaticData.getSiteColumnList(); if(siteColumnList == null || siteColumnList.size() == 0){ siteColumnList = new SiteColumnDAOImpl().getSiteColumnList(); ZCStaticData.setSiteColumnList(siteColumnList); } for(Iterator it = siteColumnList.iterator(); it.hasNext();){ SiteColumn siteColumn = (SiteColumn)it.next(); %> <OPTION value=<%=siteColumn.getId()%> > <%=siteColumn.getColumnName()%> </OPTION> <% } %> </select> </td> </tr> <tr> <td height="40" bgcolor="#FFFFCC" class="w"> 生成的Html文件名称: <input name="fileName" type="text"/> [例如:cpynews11.html 注意:文件名不能是中文]</td> </tr> <tr > <td class="w" height="40" bgcolor="#FFFFCC"> 文章标题: <input name="fileTitle" type="text"/> </td> </tr> <tr> <td bgcolor="#FFFFCC"> <fck:editor id="fileContent" basePath="" height="400px" width="800px" skinPath="/zcifmg/editor/skins/default/" toolbarSet="Default" imageBrowserURL="/zcifmg/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" linkBrowserURL="/zcifmg/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" flashBrowserURL="/zcifmg/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" imageUploadURL="/zcifmg/editor/filemanager/upload/simpleuploader?Type=Image" linkUploadURL="/zcifmg/editor/filemanager/upload/simpleuploader?Type=File" flashUploadURL="/zcifmg/editor/filemanager/upload/simpleuploader?Type=Flash"> </fck:editor> </td> </tr> <tr> <td> <input type="submit" value="提交"/> <input type="reset" value="重置"/> </td> <tr> </table> </FORM> </body> </html>
Struts action:
public ActionForward addWebPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception{ ActionForward forward = mapping.findForward("addPageSucc"); try{ WebPageForm pageForm = (WebPageForm)form; webPageService.addHtmlPage(pageForm); super.saveFailure(request,"文章添加成功!"); }catch(BusinessException be){ be.printStackTrace(); super.saveFailure(request,be.getMessage()); } return forward; }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |