You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
612 B
39 lines
612 B
package com.util;
|
|
/**
|
|
*
|
|
* HTML·ûºÅ¹ýÂËÀà
|
|
* @author Administrator
|
|
*
|
|
*/
|
|
public final class Filter {
|
|
|
|
public Filter(){
|
|
|
|
}
|
|
public static String escapeHTMLTags( String input ) {
|
|
|
|
if( input == null || input.length() == 0 ) {
|
|
return input;
|
|
}
|
|
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 if(ch=='&'){
|
|
buf.append("&");
|
|
}
|
|
else {
|
|
buf.append( ch );
|
|
}
|
|
}
|
|
return buf.toString();
|
|
}
|
|
|
|
}
|