2016-07-30 99 views
0

這是REST API有多個參數的正確方法嗎?REST API的多個參數

@GET 
@Path("/id/{userId,type,date}") 
@Nullable 
@Produces(MediaType.APPLICATION_JSON) 
List<Exercise> findExercises(
     @ApiParam(value = "User ID", required=true) @PathParam("userId") Long userId, 
     @ApiParam(value = "Type") @PathParam("type") String type, 
     @ApiParam(value = "Date") @PathParam("date") String date); 

如果不是,我該如何做到這一點?

回答

1

我想這是正確的做法:

@GET 
@Path("/id/{userId}/{type}/{date}") 
@Nullable 
@Produces(MediaType.APPLICATION_JSON) 
List<Exercise> findExercises(
     @PathParam("userId") Long userId, 
     @PathParam("type") String type, 
     @PathParam("date") String date); 
0

如下您應該分開路徑參數: @Path( 「/ ID/{用戶id}/{類型}/{日期}」)