首页 > 编程 > JSP > 正文

JSP中关于html的转换

2024-09-05 00:19:58
字体:
来源:转载
供稿:网友
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; ich = input.charat(i);
if( ch == ´<´ ) {
buf.append( "<" );
}
else if( ch == ´>´ ) {
buf.append( ">" );
}
else {
buf.append( ch );
}
}
return buf.tostring();
}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表