以下是我用于删除的代码
@Path("/studentnames")
public class StudentResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Student> getAllStudents() {
return StudentService.getAllStudents();
}
@GET
@Path("/{studentId}")
@Produces(MediaType.APPLICATION_JSON)
public Student getStudent(@PathParam("studentId") int id) {
return StudentService.getStudent(id);
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<Student> addStudent(Student student){
StudentService.addStudent(student);
return StudentService.getAllStudents();
}
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Student updateStudent(Student student) {
return StudentService.updateStudent(student);
}
@DELETE
@Path("/{studentId}")
@Produces(MediaType.APPLICATION_JSON)
public void deleteStudent(@PathParam("studentId") int id) {
StudentService.deleteStudent(id);
}
}