日期:2014-05-19 浏览次数:20736 次
//特殊字符转为Html public static String toHtml(String s) { s = Replace(s,"&","&"); s = Replace(s,"<","<"); s = Replace(s,">",">"); s = Replace(s,"\t"," "); s = Replace(s,"\r\n","\n"); s = Replace(s,"\n","<br>"); s = Replace(s," "," "); s = Replace(s,"'","'"); s = Replace(s,"\\","\"); return s; } //逆 public static String unHtml(String s){ s = Replace(s,"<br>","\n"); s = Replace(s," "," "); s = Replace(s,"<","<"); s = Replace(s,">",">"); s = Replace(s,"&","&"); return s; }
------解决方案--------------------
引进JSTL Funciton
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>