【问题标题】:encode some key's value of String URL for HTTP Get Request为 HTTP 获取请求编码一些字符串 URL 的键值
【发布时间】:2021-01-23 19:11:11
【问题描述】:

我只需要对字符串 url 的参数进行编码。 我的字符串网址是:http://127.0.0.1:8070/app/api/fetchData?channel=abc&param=status:new|addr:null|roomId:Default&group=iPh&reqtype=p1&serialNo=123890&codeId=A1_8uh&type=p

我想对 param(key) 的值进行编码。我正在开发 Spring Boot 项目。 请提出一些解决方案。

【问题讨论】:

    标签: java spring-boot get-request


    【解决方案1】:

    如果您从 Java 发出请求,您可以使用 base64 对字符串进行编码,如下所示[1]:

    String originalInput = "test input";
    String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes());

    我想我的第一个想法是用这种方式编码你想要的参数,然后将整个东西连接在一起。你想从编码参数中得到什么价值?

    [1]https://www.baeldung.com/java-base64-encode-and-decode

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-26
      • 2022-11-30
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多