使用矩阵参数创建GET请求 [英] Creating a GET request with matrix parameters

查看:142
本文介绍了使用矩阵参数创建GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用的网络服务需要矩阵参数:

The webservice I'll be using expects matrix parameters:

http://tester.com/v1/customers;lastname=Jackson;firstname=Tim;bookingreference=7Y9UIY

而不是通常的

http://tester.com/v1/customers?lastname=Jackson&firstname=Tim&bookingreference=7Y9UIY

无论如何,我可以使用Spring UriComponentsBuilder或其他方式创建请求吗?

Is there anyway I can create a request using the Spring UriComponentsBuilder or an alternative?

我知道我可以手动创建它,但希望有更精简的可用。

I'm aware that I could just create it manually but hoped there was something more streamlined available.

推荐答案

UriBuilder WebTarget 允许添加矩阵参数。

UriBuilder and WebTarget of JAX-RS allow to add matrix params.

 UriBuilder builder = ...
 builder.matrixParam("lastname", "Jackson").matrixParam("firstname", "Tim")...

这篇关于使用矩阵参数创建GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆