1.@ApiParam 顧名思義,是註解api的參數,也就是用於swagger提供開發者文檔,文檔中生成的註釋內容。前端
@ApiOperation( value = "編輯公告", notes = "編輯公告", httpMethod = "POST" ) @RequestMapping( value = "/edit", method = RequestMethod.POST ) public RequestResult edit( @ApiParam(name = "title", value = "公告標題", required = true) @RequestParam("title") String title, @ApiParam(name = "content", value = "公告內容", required = true) @RequestParam("content") String content){
2.@RequestParam,是獲取前端傳遞給後端的參數,能夠是get方式,也能夠是post方式。其中若是前端傳遞的參數和後端你接受的參數起的名字字段是一致的能夠省略不寫,也能夠直接寫@RequestParam String title,若是不一致必定要完整寫,否則獲取不到,以下面的bis_key就必須寫。後端
@ApiOperation( value = "編輯公告", notes = "編輯公告", httpMethod = "POST" ) @RequestMapping( value = "/edit", method = RequestMethod.POST ) public RequestResult edit( @ApiParam(name = "bis_key", value = "bis_key", required = true) String bisKey, @ApiParam(name = "title", value = "公告標題", required = true) @RequestParam String title, @ApiParam(name = "content", value = "公告內容", required = true) String content,
3.@PathVariable,是獲取get方式,url後面參數,進行參數綁定api
@ApiOperation(value = "刪除公告", notes = "刪除公告", httpMethod = "POST") @RequestMapping(value = "/delete/{bisKey}", method = RequestMethod.POST) public RequestResult remove(@ApiParam(name = "bisKey", value = "須要刪除的公告ids", required = true) @PathVariable String bisKey) {