Groovy 转义问号

Groovy escaping question mark

我正在使用 groovy 编写 spock 测试。 我想获取其中包含 ? 的 url 路径。 但它总是变成:

发送请求:

GET /test%3Fsearch=blub HTTP/1.1

我试过用\\/

逃脱
restClient.get(path: '/test?search='+search, requestContentType: 'application/json')

我认为您应该以更惯用的方式使用 RESTClient,例如:

restClient.get(path: '/test', query:[ search:'search' ], ... )