JAX-RS:多条路径 [英] JAX-RS: Multiple paths
本文介绍了JAX-RS:多条路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以做类似的事情?
Is it possible to do something like that?
import javax.ws.rs.GET;
import javax.ws.rs.Path;
public class xxx
{
@GET
@Path(value = "path1")
public Response m1()
{
...
}
@GET
@Path(value = "path2")
public Response m2()
{
...
}
}
我正在使用RESTEasy。
I'm using RESTEasy.
推荐答案
是的,你可以这样做,虽然你必须重命名你的方法,以便他们的签名不同。
yes you can do that although you will have to rename your methods so that their signature is different.
更新: 检查Dieter Cailliau的答案, @Path(/ {a:path1 | path2} )
可能就是你想要的......
public class BlahResource{
@GET
@Path("path1")
public Response m1(){
return Response.ok("blah").build();
}
@GET
@Path("path2")
public Response m2(){
return this.m1();
}
你可以查看JSR-311的API及其名为jersey的参考实现:
you can check JSR-311's API and it's reference implementation named "jersey" there:
这篇关于JAX-RS:多条路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文