我试着研究它。但是,由于我对此很陌生,所以无法弄清楚这个问题。我附上了几张截图,看看我现在面临的问题。
@Path("/emp")
public class EmployeeService {
@GET
@Path("/emp/{empID}")
@Produces(MediaType.APPLICATION_XML)
public Employee getEmployee(@PathParam(value = "empID") String empID) {
Employee employee = new Employee();
employee.setEmailId(empID);
employee.setName("Rony John");
employee.setEmailId("rony.java@gmail.com");
return employee;
}
@POST
@Path("/create")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Employee createEmployee(Employee employee) {
// Create logic
return employee;
}
@POST
@Path("/update")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public Employee updateEmployee(Employee employee) {
employee.setName(employee.getName() + " updated");
return employee;
}
@DELETE
@Path("/delete/{empID}")
public Response deleteEmployee(@PathParam(value = "empID") String empID) {
return Response.status(200)
.entity("Employee with " + empID + " is deleted successfully.")
.build();
}
}