spring - 如何在 URL 中使用 ^ 读取查询参数
问题描述
我正在尝试为 eBay 实现回调端点。eBay 调用此端点以将用户令牌交给应用程序。
我可以按预期定义我的端点
http://localhost:8080/api/ebay/auth
这里没有什么不寻常的。我的观点看起来像这样,非常基本:
@RestController
@RequestMapping(path = ["/api/ebay/auth"])
class EbayAuthController {
@GetMapping(path = [""])
fun getAccessToken(@RequestParam code: String) {
println("Auth code: $code")
}
}
现在 eBay 将参数code
与值一起传递
?code=v^1.1%23i^1%23r^1%23p^3%23I^3%23f^0%23t^[excluded_user_token]&expires_in=299
当我用这个数据集调用我的端点时,它返回400 Bad Request
. 我可以通过添加^
到任何请求来重现这一点。我读到这是一个不安全的字符使用 - 但问题是:Ebay 使用这个字符返回用户令牌,所以我必须阅读它。
当我传递一个样本时,http://localhost:8080/api/ebay/auth?code=123
它会按预期打印代码。
我从来没有遇到过这个问题,任何人都可以帮助我或指出正确的方向如何解决这个问题?
解决方案
根据Dirk Deyne对Spring-boot controller error when url contains brackets character 问题的回答,您可以在以下内容中指定:server.tomcat.relaxed-query-chars
application.properties
server.tomcat.relaxed-query-chars=^
推荐阅读
- php - 从循环内的包含文件中获取变量
- powershell - Powershell DSC - 对环境进行逆向工程?
- java - 何时使用 Guice 的即时绑定?
- listview - Nativescript Vue ListView - 预期的数组,得到对象
- r - 如何将 R 设置为从没有 bin 或 root 访问权限的目录运行?
- vuejs2 - 在“创建”值之后创建的 vue2“计算”值
- javascript - 将道具传递给组件的反应返回未定义
- angular - 具有延迟加载问题的角嵌套路由
- scala - 如何使用无形将字段名称映射到案例类的字段类型
- python - ValueError:无法将字符串转换为浮点数:'[0.0267469, 0.0272395, 0.0268747]'