今天使用UEditor的时候发现传到Controller里面的富文本内容是编码过的,很想当然的就以为是经过HtmlEncode过的,所以采用了Apache Common Lang包做编码解码工具,调用方法为:
import org.apache.commons.lang3.StringEscapeUtils;
String strDecode = StringEscapeUtils.unescapeHtml4(input);
调试后发现结果还是不对,仔细看了一下编码,发现其实客户端用的是escape方法,是UrlEcode,所以改用Url的编码方式:
import java.net.URLDecoder;
String strDecode = URLDecoder.decode(arg0);
两种编码解码方式,记录一下,以后备忘吧