Web services 如何在restfulget方法中传递Employee对象

Web services 如何在restfulget方法中传递Employee对象,web-services,rest,jersey,jersey-2.0,jersey-1.0,Web Services,Rest,Jersey,Jersey 2.0,Jersey 1.0,我在restfulwebservicesjaxrs2/jersy2中传递一个雇员对象表单客户端 @GET @Path("{empObj}") @Produces(MediaType.APPLICATION_XML) public Response readPK(@PathParam("empObj")Employee empObj) { //do Some Work System.out.println(empObj.getName())

我在restfulwebservicesjaxrs2/jersy2中传递一个雇员对象表单客户端

 @GET
    @Path("{empObj}")
    @Produces(MediaType.APPLICATION_XML)
    public Response readPK(@PathParam("empObj")Employee empObj) {
        //do Some Work
        System.out.println(empObj.getName());
        return Response.status(Response.Status.OK).entity(result).build();
    }
如何使用GET方法实现此对象??
通过在方法参数/类字段上使用
@PathParam
,您基本上是在告诉JAX-RS运行时将路径段(通常是字符串)注入(字符串)参数。如果您直接通过URI(查询参数、路径参数)发送对象(员工)表示,您还应该提供。请注意,在某些情况下,这是不可能的,这不是一个推荐的做法。但是,如果要在消息正文中将对象从客户端发送到服务器,只需删除
@PathParam
,并将输入流转换为您的类型:

@GET
@Path("{empObj}")
@Produces(MediaType.APPLICATION_XML)
public Response readPK(Employee empObj) {
    //do Some Work
    System.out.println(empObj.getName());
    return Response.status(Response.Status.OK).entity(result).build();
}