就是RESTful api吧,大概…
大概比较核心的就是 @RestController ,显然是继承的 Controller
@RestController@RequestMapping("/person")public class PersonController {@RequestMapping(method = RequestMethod.GET)public List<Person> getAllPerson() {List<Person> l = new ArrayList<>();l.add(new Person(1, "Chester"));return l;}@RequestMapping(value = "/{id:[\\d]+}", method = RequestMethod.GET)public Person getPerson(@PathVariable(value = "id") int id){return new Person(id, "Chester");}}
它的作用是不用你写 ResponseBody , 可以直接返回Java对象
