1
我想,我想在這裏,但不能完全肯定使用URIBuilder
...如何構建URL在Groovy
我有以下代碼:
String serverURL = getServerURL(); // ex: "http://somesrv.example.com"
String appURL = getAppURL(); // ex: "http://myapp.example.com"
我現在需要添加兩個在一起,使其產生如下:
http://somesrv.example.com/fizz?widget=http://myapp.example.com
但我不只是想用串撲(def url = serverURL + "/fizz?widget=" + appURL
)。另外,我想URL編碼等,再次,我認爲URLBuilder
是去這裏的方式,但不知道。
我見過一個例子使用JAX-RS」 UriBuilder
:
String url = UriBuilder.fromUri(serverURL).path("fizz").queryParam("widget", appURL).build();
現在我只需要弄清楚如何在Groovy中做到這一點?
爲什麼不這樣做同樣的方式在Java中呢?只需在行尾添加分號;) – topr