org.apache.commons.lang3.StringEscapeUtils的使用

StringEscapeUtils在org.apache.commons.lang3包下,可以方便的对html等东西进行转义

StringEscapeUtils.unescapeHtml3与StringEscapeUtils.unescapeHtml4的区别在于unescapeHtml4可对更多位的html进行转义,如以下例子:

		String a = " (>^ω^<)";
        System.out.println(a);
        System.out.println(StringEscapeUtils.unescapeHtml3(a));
        System.out.println(StringEscapeUtils.unescapeHtml4(a));

代码的运行结果为

在这里插入图片描述

可以看到unescapeHtml3对大于小于进行了转义,unescapeHtml4对ω进行了转义

你可能感兴趣的:(Java,html)