解决方法有两种:
第1种:
?
第2种:
/*将字串转为html格式*/
public String strToHtml(String s)
{
if (s==null||s.equals("")) return "";
s = s.replaceAll("&", "&");
s = s.replaceAll("<", "<");
s = s.replaceAll(">", ">");
s = s.replaceAll(" ", " ");
// s = s.replaceAll("/n", "
");
// s = s.replaceAll("'", "'");
return s;
}
/*将html格式转为字串*/
public String strToHtml(String s)
{
if (s==null||s.equals("")) return "";
s = s.replaceAll("&","&");
s = s.replaceAll("<","<");
s = s.replaceAll(">",">");
s = s.replaceAll(" "," ");
//s = s.replaceAll("
","/n");
//s = s.replaceAll("'","'");
return s;
}