url带?

http://ip:port/user/selectuserbyid?user_id=1

  1. /**
  2. * @param user_id
  3. * @return loginResultdto
  4. * @description 根据id查询用户
  5. * @date 2022-03-17
  6. */
  7. @ApiOperation(value = "根据id查询用户", notes = "根据id查询用户", httpMethod = "GET", response = UserResultdto.class)
  8. @RequestMapping(method = RequestMethod.GET, value = "/selectuserbyid")
  9. public CommonResult selectUserById(@RequestParam("user_id") int user_id) {
  10. User res = iUserService.selectUserById(user_id);
  11. if (res != null) {
  12. //数据库查询成功
  13. return CommonResult.success(new UserResultdto(res), "查询成功");
  14. } else {
  15. return CommonResult.failed("参数错误");
  16. }
  17. }

url/后直接是数据

  1. @RestController
  2. public class HelloController {
  3. @GetMapping("/hello/{name}")
  4. public String hello(@PathVariable("name") String name){
  5. return "你好," + name + " !";
  6. }
  7. }