对于特殊字符保存到数据库后再读出原样输出到页面
/**
*如<a href="http://www.baidu.com">test</a>原样保存到数据库,然后到页面又原样输入
* Convert the string which contains html Tag to common string.
* @param value
* string to convert.
* @return
* the result string.
*/
public static String escapeHTMLTags(String sourcestr)
{
if (sourcestr == null)
return "";
int strlen;
String restring = "";
String destr = "";
strlen = sourcestr.length();
for (int i = 0; i < strlen; i++)
{
char ch = sourcestr.charAt(i);
switch (ch)
{
case '<':
destr = "<";
break;
case '>':
destr = ">";
break;
case '\"':
destr = """;
break;
case '&':
destr = "&";
break;
case 13:
destr = "<br>";
break;
case 32:
destr = " ";
break;
default:
destr = "" + ch;
break;
}
restring = restring + destr;
}
return "" + restring;
}