0

この単純な 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ます。

コードに何か不足していますか?

4

1 に答える 1

3

多分あなたは試すことができます

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

@Path(/user) の場合

于 2012-12-04T23:47:27.167 に答える