访问rest资源时出错404

时间:2012-12-04 23:35:47

标签: java resteasy

我在使用这个简单的RestEasy服务时遇到了麻烦:

@Path("/")
public interface UserService {

    @POST
    @Path("/add")
    @Consumes(MediaType.APPLICATION_JSON)
    Response add(User user);

    @POST
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    Response update(User user);

    @GET
    @Path("/get/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    Response get(@PathParam("id") long id);

    @GET
    @Path("/getAll")
    @Produces(MediaType.APPLICATION_JSON)
    Response getAll();

}

基本上,上面的代码有效,但是当我将@Path("/")更改为@Path("/user")并访问资源时:

http://localhost:8080/user/add

它抛出错误404。与原作http://localhost:8080/UserService/add不同。

我在代码中遗漏了什么吗?

1 个答案:

答案 0 :(得分:3)

也许你可以试试

http://localhost:8080/UserService/user/add

表示@Path(/ user)

相关问题