JSP中关于html的转换
日期:2007年7月8日 作者: 查看:[大字体 中字体 小字体]-
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();
}
(出处:急速软件下载学院)
下一篇:JSP中设置HTTP应答头
