在做新闻发布的时候,添加功能,怎么把编辑器内的新闻内容的值取到,传到后台
求一个源码

解决方案 »

  1.   

    去看看FckEditor 很简单的 
      

  2.   

    下载FCKEDITOR解压放到项目webroot下
    1  配置web.xml 文件添加如下内容 
    <servlet>
    <servlet-name>Connector< servlet-name>
    <servlet-class>
    net.fckeditor.connector.ConnectorServlet
    < servlet-class>
    <load-on-startup>1</load-on-startup>
    < servlet><servlet-mapping>
    <servlet-name>Connector< servlet-name>
    <!-- Do not wrap this line otherwise Glassfish will fail to load this file -->
    <url-pattern>/fckeditor/editor/filemanager/connectors/*</url-pattern>
    < servlet-mapping>2  将文件夹 fckeditor 放到你工程的根目录中3  将 commons-fileupload-1.2.1.jar 和 commons-io-1.3.2.jar 和 java-core-2.4.1.jar 和 slf4j-api-1.5.2.jar
       和 slf4j-simple-1.5.2.jar 
       copy 到你工程中的lib 目录中
       
    4  将fckeditor.properties 和 log4j.properties 文件放到你工程中的 src目录中 5   作完前4步操作你的安将就完成了
      

  3.   


    <%@ page language="java" import="java.util.*" pageEncoding="gb2312"
    import=" net.fckeditor.*,java.util.*,java.text.SimpleDateFormat,xxfb.Xxfb,java.util.ArrayList,java.util.List,xxfb.Xxform"%>
    <%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort()
    + path + "/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <base href="<%=basePath%>"> <title>内蒙古兴安盟政务综合门户网-信息报送系统</title>
    <link href="css/css.css" rel="stylesheet" type="text/css"> <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script src="/wrmps/js/validation-framework.js"> </script>
    <script src="/wrmps/fckeditor/fckeditor.js"> </script>
    <script language="JavaScript">
    function getContentValue()
    {
           var oEditor = FCKeditorAPI.GetInstance('EditorDefault') ;
           var acontent=oEditor.GetXHTML();
           return acontent;
    }

    function checkit(){
    if(getContentValue() =="")
     {
     alert("信息内容不能为空");
     return false;
     }  
    return true;
    }
    </script>
    </head> <body leftmargin="0" topmargin="0" style="overflow-x:hidden"> <%request.setCharacterEncoding("GBK");
    int wid = Integer.parseInt(request.getParameter("wid"));
    Xxfb x = new Xxfb();
    ArrayList al = (ArrayList) x.sele_updatexx(wid);
    Iterator it = al.iterator();
    while (it.hasNext()) {
    Xxform f = (Xxform) it.next();
    String content = f.getContent().toString();
    int regedit=0;
    %>
     <form  action="adminUser.do?pare="+regedit  method="post" >

    <table width="100%" border="0" cellpadding="0" cellspacing="8">
    <tr>
    <td align="center" valign="top">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="14">
    <img src="images/table_01.gif" width="14" height="29">
    </td>
    <td width="98%" valign="top" background="images/table_02.gif">
    <span class="t14b">修改信息</span>
    </td>
    <td width="5">
    <img src="images/table_09.gif" width="5" height="29">
    </td>
    </tr>
    </table>
    <table width="100%" border="0" cellpadding="0" cellspacing="0"
    class="bk">
    <tr>
    <td align="center" valign="top">
    <table width="100%" height="300" border="0" cellpadding="0"
    cellspacing="10">
    <tr>
    <td align="center" valign="top">
    <form action="updatexx.jsp" name="form1" method="post">
    <table width="100%" border="0" cellpadding="10"
    cellspacing="1" bgcolor="#dcc691">
    <tr bgcolor="#FFFFFF">
    <td width="20%" height="40" align="center"
    bgcolor="#fffee9" class="gold12b">
    标 题:
    </td>
    <td width="80%">
    <input type="hidden" name="updatewid" value="<%=wid%>">
    <input type="text" name="textfield" class="input2"
    value="<%=f.getTitle()%>" disabled="disabled">
    </td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td height="40" align="center" bgcolor="#fffee9"
    class="gold12b">
    文章内容:
    </td>
    <td>
    <%
    FCKeditor fckEditor = new FCKeditor(request, "EditorDefault");
    fckEditor.setHeight("388");
    fckEditor.setWidth("633");
    //fckEditor.setBasePath("fckeditor/_samples/sampleslist.html");
    fckEditor.setValue(content);
    //String c = request.getParameter("EditorDefault"); //System.out.println(c);
    out.println(fckEditor);
    %>

    </td>
    </tr>
    </table>
    <%} %>
    </td>
    </tr>
    </table>
                                     
    <table width="100%" height="35" border="0" cellpadding="0"
    cellspacing="0" class="line">
    <tr>
    <td align="center" valign="middle"
    background="images/bg02.jpg">
    <input type="submit" name="Submit2" value=" 上 报 "
    class="input" onclick="return checkit()"> &nbsp;
    <input type="submit" name="Submit" value=" 返回上一级 "
    class="input" onclick="window.history.back(-1);">
    </td>
    </tr>
    </table>

    </td>
    </tr>
    </table>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="4">
    <img src="images/table_06.gif" width="4" height="4">
    </td>
    <td background="images/table_11.gif">
    <img src="images/table_07.gif" width="1" height="4">
    </td>
    <td width="4">
    <img src="images/table_08.gif" width="4" height="4">
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>

    </body>
    </html>