首页 > 解决方案 > API 中的 LocalDate 作为 javax.ws.rs.QueryParam

问题描述

我想使用LocalDateas @QueryParam,但我收到编译时错误 as

Incorrect parameter type 
Inspection info: Checks types of parameters annotated @PathParam, @QueryParam, etc. The type of the annotated parameter, field or property must either:
Be a primitive type.
Have a constructor that accepts a single String argument.
Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)).
Have a registered implementation of ParamConverterProvider JAX-RS extension SPI that returns a ParamConverter instance capable of a "from string" conversion for the type.
Be List<T>, Set<T> or SortedSet<T>, where T satisfies 2, 3, or 4 above. The resulting collection is read-only.

我在我的资源类中使用如下

@QueryParam("lastLoginStartDate") LocalDate startDate

有什么方法可以在 API 中使用LocalDatejavax.ws.rs.QueryParam

标签: javajerseydropwizardquery-parametersqueryparam

解决方案


推荐阅读