小编Mia*_*Mia的帖子

如何在 Kotlin 中对查询参数进行 url 编码

我是 Kotlin 的新手,我正在尝试对具有查询参数的 url 进行 url 编码。

private const val HREF = "date?July 8, 2019"
private const val ENCODED_HREF = print(URLEncoder.encode(HREF, "utf-8"))
private const val URL = "www.example.com/"+"$ENCODED_HREF"
Run Code Online (Sandbox Code Playgroud)

错误:常量“val”的类型为“Unit”。只允许使用原语和字符串private const val ENCODED_HREF

urlencode query-parameters kotlin

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

kotlin ×1

query-parameters ×1

urlencode ×1