文本编辑器js+java

来源:互联网 发布:数独出题软件 编辑:程序博客网 时间:2024/05/16 10:14



<%
request.setCharacterEncoding("gbk");
String htmlData = request.getParameter("content") != null ? request.getParameter("content") : "";
%>


界面:


 


记得要在后台:


    public static String htmlspecialchars(String str) {
            str = str.replaceAll("&", "&amp;");
            str = str.replaceAll("<", "&lt;");
            str = str.replaceAll(">", "&gt;");
            str = str.replaceAll("\"", "&quot;");
            str = str.replaceAll("\'", "&apos;");
            //str = str.replaceAll("=", "&equals;");
            return str;

            

        }

下面是读取clob类型封装的一个方法:

public static String readClob(Connection con, String term, String columnName,
            String tableName)
    {
        String content = "";
        try
        {
            con.setAutoCommit(false);
            Statement stmt = con.createStatement();
            ResultSet rs_clob = stmt.executeQuery("select " + columnName
                    + "  from   " + tableName + " where 1=1 " + term);
            oracle.sql.CLOB contents = null;
            while (rs_clob.next())

            { // 取出CLOB对象
                contents = (oracle.sql.CLOB) rs_clob.getClob(columnName);
            }
            BufferedReader a = new BufferedReader(contents.getCharacterStream()); // 以字符流的方式读入BufferedReader
            String str = "";
            while ((str = a.readLine()) != null) {
                content = content.concat(str); // 最后以String的形式得到
            }
            con.commit();
            con.setAutoCommit(true);
            
        } catch (Exception e)
        {
            System.out.println("出现异常");
            e.printStackTrace();
            try
            {
                con.rollback();
            }
            catch (Exception e1)
            {
                System.out.println("回滚出现异常!");
                e1.printStackTrace();
            }
        }
        return content;
    }