2种实现方式
//返回Json的做法1
@RequestMapping(value="/student/{id}",method=RequestMethod.GET)
public @ResponseBody Student getStudent(@PathVariable("id") String id){
System.out.println("id ==:"+id);
Student student = new Student("jacob",23,"guangzhou ");
return student;
}
//返回Json的做法2
@RequestMapping(value="/student2/{id}",method=RequestMethod.GET)
public ResponseEntity<Student> getStudent2(@PathVariable("id") String id){
System.out.println("id ==:"+id);
Student student = new Student("jacob",23,"guangzhou ");
return new ResponseEntity<Student>(student, HttpStatus.OK);
}