@Test public void testSaveEmployee(){ Department department = new Department(1,"研发部"); Employee employee = new Employee(1,"scott",department); Response response = target("employee").request().post(Entity.entity(employee,MediaType.APPLICATION_XML)); System.out.println(response.getStatus()); System.out.println(response.readEntity(String.class)); }
@POST public Employee saveEmployee(Employee employee){ return employee; }
EmployeeRestService { @POST public Employee saveEmployee(Employee employee){ return employee; } }
EmployeeRestService { @POST public Employee saveEmployee(Employee employee){ return employee; }  }
EmployeeRestService { @POST public Employee saveEmployee(Employee employee){ return employee; }  @Path("/v1") @GET List<Employee> getEmployees(); @Path("{id}") @GET Employee getEmployee(@PathParam("id")int id); @POST Employee saveEmployee(Employee employee); @PUT Employee updateEmployee(Employee employee); @DELETE @Path("{id}") Employee deleteEmployee(@PathParam("id")int id); }
EmployeeRestService { @POST public Employee saveEmployee(Employee employee){ return employee; }  @Path("/v1") @GET List<Employee> getEmployees(); @Path("{id}") @GET Employee getEmployee(@PathParam("id")int id); @POST Employee saveEmployee(Employee employee); @PUT Employee updateEmployee(Employee employee); @DELETE @Path("{id}") Employee deleteEmployee(@PathParam("id")int id);  }