我已经使用服务器和客户端的RESTeasy。客户服务股份接口服务器:如何在RESTeasy客户端中设置路径参数
public interface Service {
@Path("/start")
@GET
void start();
}
这种服务的实施必然路径/api
,所以方法start()方法是完整路径/api/start
上访问。在客户端代码是非常简单的:
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
Service service = ProxyFactory.create(Service.class, "http://server/api");
service.start();
但我想有路不区分大小写的,所以在它的正则表达式我假路径参数:
public interface Service {
@Path("/{start:[Ss]tart}")
@GET
void start();
}
现在客户ProxyFactory里不知道价值替代路径参数{start}
并且不做任何替换,客户端以例外You did not supply enough values to fill path parameters
结束。
但是,当我尝试使用路径参数作为方法参数,它的工作原理。
public interface Service {
@Path("/{start:[Ss]tart}")
@GET
void start(@PathParam("start") String param);
}
如何在RESTeasy客户端中为假路径参数指定值?
谢谢。
对于那些谁感兴趣的话,现在我使用两个单独的接口,用于服务器(使用正则表达式)和客户端(与普通小写路径)。我将它报告为RESTeasy bug跟踪器的增强版,我们将看到,https://issues.jboss.org/browse/RESTEASY-634 – mschayna 2011-12-19 13:44:04
更新:我比一年前更换了Jersey REST服务器。泽西支持客户端完全以另一种方式,所以我不得不面对另一种问题:) – mschayna 2014-02-05 14:14:56