URL编码解码问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/guanripeng/article/details/81005134

解码:

////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;
}
阅读更多
换一批

没有更多推荐了,返回首页