我有这个Jersey POST资源:
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Response blablabla(InputStream inputStream,
@BeanParam ImportParams importParams) throws IOException, JAXBException, SAXException {
这是ImportParams类:
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发布到资源时,只有我在URL中的问号后指定的第一个查询参数由jersey读取:
curl -XPOST -H"Content-Type: application/xml" -H"authorization: bearer $TOKEN" -d@$3 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@$3 http://localhost:8585/services/stop_places/netex?importType=MERGE&forceStopType=TRAM_STATION
==> importType has the right value and forceStopType is null
我以前曾经多次使用过@BeanParam而且它曾经工作过,所以我一定会错过一些明显的东西....感谢您的帮助
答案 0 :(得分:0)
curl -XPOST -H"Content-Type: application/xml" -H"authorization: bearer $TOKEN" -d@$3 "http://localhost:8585/services/stop_places/netex?forceStopType=TRAM_STATION&importType=MERGE"