HttpServletRequest
@ApiOperation(value = "数独", notes = "数独游戏模型获取") @ApiImplicitParam(name = "difficulty" , value = "难度级别, easy(简单)、normal(普通)、hard(困难)、veryhard(非常困难); 默认easy" , paramType = "query" //参数位置说明 , defaultValue = "easy" //默认值 ,required = false //,example = "easy(简单)、normal(普通)、hard(困难)、veryhard(非常困难); 默认easy" ) @GetMapping(value = {"/getSudoku/dif"}) public Object getSudoku(@RequestParam(required = false)String difficulty, HttpServletRequest req) { log.info("转发链接:{}", URL + difficulty); log.info("请求地址:[{}]",req.getRequestURL().toString()); log.info("请求参数:[{}]",req.getQueryString()); log.info("请求方式:[{}]",req.getMethod()); return restTemplate.getForObject(URL + difficulty, Object.class); }
打印日志
2021-12-14 23:42:10.571 INFO 27812 --- [nio-8080-exec-1] com.example.controller.HttpController : 请求地址:[http://localhost:8080/getSudoku/dif] 2021-12-14 23:42:10.571 INFO 27812 --- [nio-8080-exec-1] com.example.controller.HttpController : 请求参数:[difficulty=easy] 2021-12-14 23:42:10.571 INFO 27812 --- [nio-8080-exec-1] com.example.controller.HttpController : 请求方式:[GET]