1.编码字符串
public static String encode(String s, String encodeType) { if (s == null || s.equals("")) { return ""; } if (encodeType == null || encodeType.equals("")) { return s; } try { return URLEncoder.encode(s, encodeType); } catch (Exception e) { } return s; }
2.解码字符串
public static String decode(String s, String encodeType) { if (s == null || s.equals("")) { return ""; } if (encodeType == null || encodeType.equals("")) { return s; } try { s = URLDecoder.decode(s, encodeType); } catch (Exception e) { } return s; }
时间: 2024-11-05 14:50:39