预览模式: 普通 | 列表
07-08
14

关于StringEscapeUtils介绍

StringEscapeUtils来做HTML的转化,介绍如下:

引用内容 引用内容
escapeHtml

public static String escapeHtml(String str)

Escapes the characters in a String using HTML entities.

For example:

查看更多...

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1054
07-08
14

在jsp环境中配置使用FCKEditor

  FCKeditor是sourceforge.net上面的一个开源项目,主要是实现在线网页编辑器的功能,可以让web程序拥有如MS Word这样强大的编辑功能。官方网站为http://www.fckeditor.net ,在服务器端支持ASP.Net、ASP、ClodFusion、PHP、Java等语言,并且支持IE 5+、Mozilla 、Netscape等主流浏览器。
  首先在官方网站下载fckeditor,注意有两个包,一个是主文件,一个是jsp整合包的。

  1、解压FCKeditor_2.2.zip,(FCKeditor主文件),将FCKeditor目录复制到网站根目录下,

  2、解压FCKeditor-2.3.zip,(jsp,FCKeditor整合包),作用:This is the JSP Integration Pack for using FCKeditor inside a java server page without the complexity of using a Java scriptlets or the javascript api.

  3、将FCKeditor-2.3/web/WEB-INF/web.xml中的两个servlet,servlet-mapping定义复制到自已项目的web.xml文件中
修改

查看更多...

分类:Java&Jsp | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 628
07-08
14

解析html spec的类方法,HTML转义

比如说,我要在我的web页面里面产生"<B>"这样一个字符串。我可不想写

举例:<B>转换为& l t ; B & g t ;  ,也就是HTMLEncode与HTMLDecod转换

手动编写一个类

public static String enableTag(String input) throws IOException {
if (input == null) {
return null;

查看更多...

Tags: spec

分类:学习 | 固定链接 | 评论: 2 | 引用: 0 | 查看次数: 1129
07-08
14

今天碰到的两个细节问题解决方法

两个小问题,具体如下
一,关于插入单引号'到数据库出错问题<<数据表test,字段有title(varchar),content(text)>>

在上一个问题test1.jsp中有一个form指向test2.jsp,在test2.jsp中插入得到的数据,test2.jsp的部分代码如下:
String title=new String(request.getParameter("title").getBytes("iso-8859-1"),"gb2312");
String content=new String(request.getParameter("content").getBytes("iso-8859-1"),"gb2312");
String sql="insert into test(title,content) values('"+title+"','"+content+"')";
stmt.executeUpdate(sql);
当test1.jsp输入的数据有单引号'时,就出现错误,错误肯定出在sql语句上,不知道怎么处理?

查看更多...

分类:Java&Jsp | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 935
07-08
14

HtmlEncode 以及HtmlDecode 方法

    当我们想在网页上显示HTML 标注时,若在网页中直接输出则会被浏览器解译为HTML 的内容,所以要透过Server 对象的HtmlEncode 方法将它编码再输出;而若要将编码后的结果译码回原本的内容,则使用HtmlDecode 方法。下列程序代码范例使用HtmlEncode 方法将「<B>HTML内容</B>」编码后输出至浏览器,再利用HtmlDecode 方法将把编码后的结果译码还原:

<Html>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Dim strHtmlContent As String
strHtmlContent=Server.HtmlEncode("<B>HTML 内容</B>")
Response.Write(strHtmlContent)
Response.Write("<P>")

查看更多...

分类:Css&Ps | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 901
07-08
14

字符操作

数据库中字段content储存的内容其中的段落格式,在ASP中可以借用几个函数来做处理,比如说保持原有格式,UBB格式原样输出,FCK格式(html)原样输出:
一、UBB格式原样输出
Newarticle = Newarticle & "<h1 class=""ContentTitle""><strong>"&UnCheckStr(HtmlEncode(RSn("log_Title")))&"</strong></h1>"
二、HTML格式原样输出
Newarticle = Newarticle & "<div class=""NewBody""> "&UnCheckStr(HtmlDecode(Left(RSn("log_Content"),200))) &"... "
三、普通原始输出
Newarticle = Newarticle & "<h1 class=""ContentTitle""><strong>"&RSn("log_Title")&"</strong></h1>"

查看更多...

分类:Css&Ps | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 650