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