@Test public void testHtmlEscapeOnce() { String src = "&amp;<span class=\"java\"/>"; String target = Util.htmlEscapeOnce(src); assertEquals("&amp;amp;&lt;span class=&quot;java&quot;/&gt;", target); }
public static String htmlEscapeOnce(String s) { if (StringUtils.isBlank(s)){ return s; } s = s.replaceAll("&", "&amp;"); s = s.replaceAll("<", "&lt;"); s = s.replaceAll(">", "&gt;"); s = s.replaceAll("\"", "&quot;"); return s; }
Util { public static String htmlEscapeOnce(String s) { if (StringUtils.isBlank(s)){ return s; } s = s.replaceAll("&", "&amp;"); s = s.replaceAll("<", "&lt;"); s = s.replaceAll(">", "&gt;"); s = s.replaceAll("\"", "&quot;"); return s; } }
Util { public static String htmlEscapeOnce(String s) { if (StringUtils.isBlank(s)){ return s; } s = s.replaceAll("&", "&amp;"); s = s.replaceAll("<", "&lt;"); s = s.replaceAll(">", "&gt;"); s = s.replaceAll("\"", "&quot;"); return s; }  }
Util { public static String htmlEscapeOnce(String s) { if (StringUtils.isBlank(s)){ return s; } s = s.replaceAll("&", "&amp;"); s = s.replaceAll("<", "&lt;"); s = s.replaceAll(">", "&gt;"); s = s.replaceAll("\"", "&quot;"); return s; }  static String toStr(byte[] data); static byte[] toBytes(String str); static double convertDouble(String src); static double convertDouble(String src, double defaultValue); static int convertInt(Object obj); static int convertInt(Object obj, int defaultValue); static long convertLong(String src); static long convertLong(String src, long defaultValue); static void trim(StringBuffer sb,char c); static String urlDecoder(String s, String charcoding); static String urlEncoder(String s, String charcoding); static String toEscChar(String s); static String htmlEscapeOnce(String s); static String htmlUnEscapeOnce(String s); static String getPicIdFromUrl(String url); static String getProfileImgUrl(long uid, int size, long iconver, byte gender); static long getVersionFromImgUrl(String imageUrl); static String toEscapeJson(String s); }
Util { public static String htmlEscapeOnce(String s) { if (StringUtils.isBlank(s)){ return s; } s = s.replaceAll("&", "&amp;"); s = s.replaceAll("<", "&lt;"); s = s.replaceAll(">", "&gt;"); s = s.replaceAll("\"", "&quot;"); return s; }  static String toStr(byte[] data); static byte[] toBytes(String str); static double convertDouble(String src); static double convertDouble(String src, double defaultValue); static int convertInt(Object obj); static int convertInt(Object obj, int defaultValue); static long convertLong(String src); static long convertLong(String src, long defaultValue); static void trim(StringBuffer sb,char c); static String urlDecoder(String s, String charcoding); static String urlEncoder(String s, String charcoding); static String toEscChar(String s); static String htmlEscapeOnce(String s); static String htmlUnEscapeOnce(String s); static String getPicIdFromUrl(String url); static String getProfileImgUrl(long uid, int size, long iconver, byte gender); static long getVersionFromImgUrl(String imageUrl); static String toEscapeJson(String s);  }