1,@ResponseBody注解
@ResponseBody将java对象转为json格式的数据,返回页面。
一般@RestController的作用就相当于@ResponseBody+@Controller
一般使用:
@RestController
@RequestMapping("/sys/student")
public class StudentController {
}
2,@RequestBody注解
@RequestBody使用json的格式传递数据,把json数据封装到对象中来。如果用 @RequestBody,那么就需要使用post方式提交。参数required = false:表示参数值可以空。
一般使用:
@ApiOperation(value = "带条件分页讲师列表")
@PostMapping("page/{page}/{limit}")
public String pageListCondition(
@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable Long page,
@ApiParam(name = "limit", value = "每页记录数", required = true)@PathVariable Long limit,
@RequestBody(required = false) StudentQuery studen