Java @Path注释中的Path参数,哪个更好

Java @Path注释中的Path参数,哪个更好,java,rest,path,jax-rs,query-parameters,Java,Rest,Path,Jax Rs,Query Parameters,我问了一个简单的问题 案例:需要编写看起来像@Path{id}/{type}的端点 仅静态ID和类型 静态路径也是 你们觉得用哪个更好?我同意 @Path("{id}/{type}") public void doSth(@PathParam("id") String id, @PathParam("type") String type) {} 它尊重Java命名约定 它比你所拥有的可读性强得多 它比你的短 IDE,然后框架和/或您的测试将告诉您,如果您碰巧在其中一个字符串中输入了错误,那么这

我问了一个简单的问题

案例:需要编写看起来像@Path{id}/{type}的端点

仅静态ID和类型

静态路径也是

你们觉得用哪个更好?我同意

@Path("{id}/{type}")
public void doSth(@PathParam("id") String id, @PathParam("type") String type) {}
它尊重Java命名约定 它比你所拥有的可读性强得多 它比你的短 IDE,然后框架和/或您的测试将告诉您,如果您碰巧在其中一个字符串中输入了错误,那么这几乎是不可能的。
你认为什么更好?
static final String PATH_ID = "{" + ID + "}";
static final String PATH_TYPE = "{" + TYPE + "}";

@Path(PATH_ID + SLASH + PATH_TYPE)
public void doSth(@PathParam(ID) String Id, @PathParam(TYPE) String type) {}
@Path("{id}/{type}")
public void doSth(@PathParam("id") String id, @PathParam("type") String type) {}