Jersey 只从@BeanParam 参数中读取第一个@QueryParam

Jersey reading only first @QueryParam out of @BeanParam parameters

我有这个球衣 POST 资源:

@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Response blablabla(InputStream inputStream, 
@BeanParam ImportParams importParams) throws IOException, JAXBException, SAXException {

这是 ImportParams class :

public class ImportParams {
    @QueryParam(value = "importType")
    public ImportType importType = ImportType.MERGE;

    @ApiParam("Force stop point type for all stop points in file. Useful if no modality defined in the netex file.")
    @QueryParam(value = "forceStopType")
    public StopTypeEnumeration forceStopType;

}

当我使用 curl 到 post 到资源时,只有我在 URL 中问号后指定的第一个查询参数被 jersey 读取:

curl -XPOST -H"Content-Type: application/xml" -H"authorization: bearer $TOKEN" -d@  http://localhost:8585/services/stop_places/netex?forceStopType=TRAM_STATION&importType=MERGE

==> forceStopType has the right value, and importType is null

curl -XPOST -H"Content-Type: application/xml" -H"authorization: bearer $TOKEN" -d@  http://localhost:8585/services/stop_places/netex?importType=MERGE&forceStopType=TRAM_STATION

==> importType has the right value and forceStopType is null

我以前多次使用@BeanParam 并且它曾经有效,所以我一定遗漏了一些明显的东西....感谢您的帮助

哈哈发现了 - 愚蠢的我。当 cURLing :

时,必须在 URL 周围加上双引号
curl -XPOST -H"Content-Type: application/xml" -H"authorization: bearer $TOKEN" -d@  "http://localhost:8585/services/stop_places/netex?forceStopType=TRAM_STATION&importType=MERGE"