注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发JSP → 文章内容

jsp中关于html的转换

作者:佚名 来源:不详 发布时间:2007-11-29 23:49:42

  作者:blackwhites

请看下面这个例子
public static String escapeHTMLTags( String input ) {
// Check if the string is null or zero length -- if so, return what was sent in.
if( input == null || input.length() == 0 ) {
return input;
}
// Use a StringBuffer in lieu of String concatenation -- it is much more efficient this way.
StringBuffer buf = new StringBuffer();
char ch = ´ ´;
for( int i=0; i<input.length(); i++ ) {
ch = input.charAt(i);
if( ch == ´<´ ) {
buf.append( "<" );
}
else if( ch == ´>´ ) {
buf.append( ">" );
}
else {
buf.append( ch );
}
}
return buf.toString();
}


  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved