我可以创建这样的路径吗

huangapple 未分类评论48阅读模式
英文:

Can I make a path like that

问题

你好,我有一个类似这样的类:

@Path("infected")
public class Resource{

    @GET
    @Path("city/{infected}")
    public Response selectInfectadosCiudad(@PathParam("infected") String nombre){
        ...
    }
}

但是当我尝试访问 .../infected/city/123,例如,它给我返回一个 404 错误,所以我猜想不能调用 city/{infected},也就是说在 PathParam 之前不能使用 city/,我理解得对吗?

英文:

Hello guys I a class like that:

@Path("infected")

public class Resource{

     @GET
    @Path("city/{infected}")
    public Response selectInfectadosCiudad(@PathParam("infected") String nombre){
    ...}
} 

But when I try to go to .../infected/city/123 for example it gives me a 404, so I suppose that you can't call city/{infected} I mean you cant use city/ before the Pathparam am I correct?

答案1

得分: 0

你可以尝试在路径之前添加 '/'

    @Path("/infected")

    public class Resource{

    @GET
    @Path("/city/{infected}")
    public Response selectInfectadosCiudad(@PathParam("infected") String nombre){
    ...}
    }

我不确定这是否有效但可以尝试一下
英文:

Can you try to add '/' before the path

@Path("/infected")

public class Resource{

@GET
@Path("/city/{infected}")
public Response selectInfectadosCiudad(@PathParam("infected") String nombre){
...}
}

I'm not sure if this will work or not but try it

huangapple
  • 本文由 发表于 2020年5月30日 07:21:36
  • 转载请务必保留本文链接:https://java.coder-hub.com/62095924.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定