在同一个@Path上创建多个GET映射

时间:2018-01-14 14:31:34

标签: java rest tomcat servlets jax-rs

@Path("motorcycle")
public class MotorcycleRecource {
@GET
  @Path("/search")
  @Produces("application/json")
  public Motorcycle getMotorcycleByYear(@QueryParam("year") Integer year) {
    return motorcycleService.getMotorcycleByYear(year);
  }

  @GET
  @Path("/search")
  @Produces("application/json")
  public Motorcycle getMotorcycleByEngineCapacity(@QueryParam("engineCapacity") Integer engineCapacity) {
    return motorcycleService.getMotorcycleByEngineCapacity(engineCapacity);
  }
}

我想在我的服务器上使用相同的路径创建2个映射,但是当我尝试编译器时会出现大量错误和异常 我想要两个映射都在摩托车/搜索映射,所以我可以做 摩托车/搜索?年= 摩托车/搜索?engineCapacity =

0 个答案:

没有答案