jaxrs变量@Path [英] jaxrs variable @Path

查看:263
本文介绍了jaxrs变量@Path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的用jax-rs注释的方法

I have a method annotated with jax-rs like this

@POST
@Path("/somepath")
public Response testPost(...)

我想使用Java字符串常量(从配置中检索)来代替"/somepath".有可能吗?

I would like to use instead of "/somepath" a java string constant (retrieved from configuration). Is that possible?

我知道我可以做@Path({somepath}) 然后使用@PathParam替换它,但这是调用者传递动态参数的另一种用例.

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.

推荐答案

在Java中,注释参数必须是编译时常量. 因此,您将无法在@Path批注中使用配置检索的值.

In java, annotation parameters must be compile-time constants. Thus, you will not be able to use configuration retrieved values in the @Path annotation.

这篇关于jaxrs变量@Path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆