Java getPathParameters()之间的差异(&;getQueryParameters()

Java getPathParameters()之间的差异(&;getQueryParameters(),java,web-services,Java,Web Services,我是Web服务新手&在创建接受GET请求的Web服务时,我发现了两种可以读取URL参数的方法: UriInfo的getPathParameters()和getQueryParameters()。当我尝试执行这两个命令时,我得到了相同的输出。以下是我尝试运行的代码: @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) public String process

我是Web服务新手&在创建接受GET请求的Web服务时,我发现了两种可以读取URL参数的方法:

UriInfo的getPathParameters()和getQueryParameters()。当我尝试执行这两个命令时,我得到了相同的输出。以下是我尝试运行的代码:

@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
public String processGETReq(@Context UriInfo pUriInfo) {
    MultivaluedMap<String, String> queryParams = pUriInfo.getQueryParameters();
    MultivaluedMap<String, String> pathParams = pUriInfo.getPathParameters();
    Set<Entry<String, List<String>>> lQueryParamsSet = queryParams.entrySet();
    Set<Entry<String, List<String>>> lPathParamsSet = pathParams.entrySet();

    for (Entry<String, List<String>> lQueryEntrySet : lQueryParamsSet) {
        System.out.println(lQueryEntrySet.getValue());
        System.out.println(lQueryEntrySet.getKey());
    }

    for (Entry<String, List<String>> lPathEntrySet : lPathParamsSet) {
        System.out.println(lPathEntrySet.getValue());
       System.out.println(lPathEntrySet.getKey());
    }
}
@GET
@产生({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML,MediaType.TEXT_PLAIN})
公共字符串processGETReq(@Context-UriInfo-pUriInfo){
多值Map queryParams=pUriInfo.getQueryParameters();
多值Map pathParams=pUriInfo.getPathParameters();
Set lQueryParamsSet=queryParams.entrySet();
Set lPathParamsSet=pathParams.entrySet();
对于(条目lQueryEntrySet:lQueryParamsSet){
System.out.println(lQueryEntrySet.getValue());
System.out.println(lQueryEntrySet.getKey());
}
对于(条目lpathtryset:lPathParamsSet){
System.out.println(lpatentryset.getValue());
System.out.println(lpatentryset.getKey());
}
}
两者的输出相同。所以,我很想知道他们之间的区别。试图从文档()中获取,但未正确获取差异

提前感谢您的回答

/clients/123/sales?sort=asc

clientId=123
是一个路径参数,
sort=asc
是一个查询参数。

更准确地说:如果wbeservice像
/clients/${clientId}/sales
那样定义了url,那么
/clientId/sales?sort=asc
将具有路径参数
clientId=123
和查询参数
sort=asc