URL编码解码问题

解码:

////url解码获取图书类别
    public static String URLDecoderString(String str) {//url解码
        String result = "";
        if (null == str) {
            return "";
        }
        try {
            result = URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }

编码:

public static String getURLEncoderString(String str) {//url编码
  String result = "";
  if (null == str) {
  return "";
  }
  try {
  result = java.net.URLEncoder.encode(str, "UTF-8");
  } catch (UnsupportedEncodingException e) {
  e.printStackTrace();
  }
  return result;
}
发布了42 篇原创文章 · 获赞 15 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/guanripeng/article/details/81005134
今日推荐