问题
I have a method annotated with jax-rs like this
@POST
@Path("/somepath")
public Response testPost(...)
I would like to use instead of "/somepath" a java string constant (retrieved from configuration). Is that possible?
I know that I can do @Path({somepath}) and then use @PathParam to replace it but that's a different use case where the caller passes a dynamic param.
回答1:
In java, annotation parameters must be compile-time constants. Thus, you will not be able to use configuration retrieved values in the @Path annotation.
来源:https://stackoverflow.com/questions/30243540/jaxrs-variable-path