<%
request.setCharacterEncoding("gbk");
String htmlData = request.getParameter("content") != null ? request.getParameter("content") : "";
%>
界面:
记得要在后台:
public static String htmlspecialchars(String str) {
str = str.replaceAll("&", "&");
str = str.replaceAll("<", "<");
str = str.replaceAll(">", ">");
str = str.replaceAll("\"", """);
str = str.replaceAll("\'", "'");
//str = str.replaceAll("=", "=");
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;
}