jaxrs variable @Path

可紊 提交于 2019-12-25 02:57:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!