´ÊÓï½âÊÍ | ±¾´ÊÓï½âÊ͹±Ï×Õß:
ckage com.example.demo.controller; import com.example.demo.model.Student; import com.example.demo.service.StudentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController public class StudentController { @Autowired private StudentService studentService; @RequestMapping("/students") public List getAllStudents() { return studentService.getAllStudents(); } @RequestMapping("/students/{id}") public Student getStudent(@PathVariable String id) { return studentService.getStudent(id); } @RequestMapping(method = RequestMethod.POST, value = "/students") public void addStudent(@RequestBody Student student) { studentService.addStudent(student); } @RequestMapping(method = RequestMethod.PUT, value = "/students/{id}") public void updateStudent(@RequestBody Student student, @PathVariable String id) { studentService.updateStudent(id, student); } @RequestMapping(method = RequestMethod.DELETE, value = "/students/{id}") public void deleteStudent(@PathVariable String id) { studentService.deleteStudent(id); } }
±§Ç¸£¬´ËÒ³ÃæµÄÄÚÈÝÊÜ°æȨ±£»¤£¬¸´ÖÆÐè¿Û³ý´ÎÊý£¬´ÎÊý²»×ãʱÐ踶·Ñ¹ºÂò¡£
ÈçÐèÏÂÔØÇëµã»÷£ºµã»÷´Ë´¦ÏÂÔØ
ɨÂ븶·Ñ¼´¿É¸´ÖÆ
Ðí¿ÉÖ¤ | Ðí¿É | ÐÇÐÎÍØÆË | ÏûÏ¢ÀàÐÍ | ϵͳÊý¾Ý±¸·Ý | ÎïÀíÍøÔª | ÎïÀíÁ´Â· | ÎÀÐÇ´«Êä | ÍøÔªID | Íø¹ØIP | ÍⲿÍøÂç | ÍØÆËÊÓͼ |