JAX-RS注入URI参数的值

时间:2018-01-18 16:14:54

标签: java xml jax-rs postman

我正在尝试使用以下方法通过id获取用户:

@Path("/v1/user/")
public class UserRestService extends BaseRestWebService {

        @GET
        @Path("/customers/{id}")  
        @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
        public Catalog getCustomerById(@Context HttpServletRequest httpServletRequest, @PathParam("id") String userId){

            IlsCustomer customer = getUserService().getUserById(IlsCustomer.class, Long.parseLong(userId));


            Catalog catalog = new Catalog();


            catalog.add(customer);
            return catalog;
        }


}

当我输入时,我正在使用邮递员和邮递员:https://localhost:8181/iPCP/restServices/v1/user/customers/6560
我收到了错误:

The page cannot be found (404)
You tried to access a page that does not exist. Please check the entered URL.

但如果我输入网址:https://localhost:8181/iPCP/restServices/v1/user/customers
回复是:{}

0 个答案:

没有答案