Java RestEasy:@PathParam在字符串有空格时返回第一个单词

Java RestEasy:@PathParam在字符串有空格时返回第一个单词,java,jboss,jax-rs,resteasy,wildfly,Java,Jboss,Jax Rs,Resteasy,Wildfly,我的API端点看起来像 @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("groups/{groupName}") public Response getCategoriesByGroupName(@PathParam("groupName") @Nonnull final String groupName) { return Response.ok(getCat

我的
API
端点看起来像

@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("groups/{groupName}")
public Response getCategoriesByGroupName(@PathParam("groupName") @Nonnull final String groupName) {
    return Response.ok(getCategoryTO().getCategoriesByGroupName(categoryManager, groupName)).build();
}
当我试图到达终点时

curl -H"Content-Type: application/json" -H"BEARER:792345452:78f7f8a4-a8c9-454a-93a8-6633a1076781:169000000"  "https://myapp.com/rest/categories/groups/Utilities"
我得到了正确的
JSON
返回,这意味着
groupName
Utilities

但当我这么做的时候

curl -H"Content-Type: application/json" -H"BEARER:792345452:78f7f8a4-a8c9-454a-93a8-6633a1076781:169000000"  "https://myapp.com/rest/categories/groups/Food & Drink"
我将服务器错误视为

Caused by: javax.ejb.EJBException: javax.persistence.NoResultException: no categories exists with groupName: Food
问题是,
groupName
被替换为
Food
,而不是
Food&Drink

我尝试使用其他
groupName
s,发现每当我的
groupName
有空格时,只有第一个单词被替换为
groupName

如何解决此问题,使传入
URL
的整个字符串变为
groupName


我的服务器部署在与我的端点无关的
Wildfly 8

正如@Sotirios所提到的,在将URL发送到服务器之前,我需要对其进行编码

当我这么做的时候,事情开始起作用了

curl -H"Content-Type: application/json" -H"BEARER: 792345452:78f7f8a4-a8c9-454a-93a8-6633a1076781:169000000"  "https://myapp.com/rest/categories/groups/Food%20%26%20Drink"

[{"id":"9b1e97f2-ac7d-4caf-85fc-476cd97dd6cb","name":"Alcohol & Bars","groupName":"Food & Drink"}]

&
是一个特殊字符。你需要对它进行编码。你能指导我怎么做吗?使用
urlcoder.encode(stringToEncode,“UTF-8”)URL编码是一种常见做法。您不仅需要用
%20