如何使用groovy代码获取url中的数据?
我想使用groovy代码从url获取缺陷id(在tasktop中构建自定义代码) 例如:我将生成一个动态url,比如www.xyz.com/abc/defect\u 123/现在我要检索始终从第17位开始的字母。然后返回字符串 请帮忙。。如何使用groovy代码获取url中的数据?,groovy,rtc,tasktop,Groovy,Rtc,Tasktop,我想使用groovy代码从url获取缺陷id(在tasktop中构建自定义代码) 例如:我将生成一个动态url,比如www.xyz.com/abc/defect\u 123/现在我要检索始终从第17位开始的字母。然后返回字符串 请帮忙。。 提前感谢这里有两种可能性。请注意,“子字符串”选项非常严格,始终从第16位开始(如果域从www.xyz.com更改为www.xyz.com会发生什么情况?) 您应该在UrlMappings.groovy文件中将其定义为动态url: “www.xyz.com/a
提前感谢这里有两种可能性。请注意,“子字符串”选项非常严格,始终从第16位开始(如果域从www.xyz.com更改为www.xyz.com会发生什么情况?)
您应该在UrlMappings.groovy文件中将其定义为动态url:
“www.xyz.com/abc/$defect\u id”(控制器:'YourController',操作:'method\u name')
使用params.defect\u id
def str = 'www.xyz.com/abc/defect_123/';
def pieces = str.tokenize('/'); // prints defect_123
def from16 = str.substring(16); // prints defect_123/
println from16;
println pieces.last();