(1)Get请求

  • RequestParam:设置Get键值对
  • PathVariable:设置路径变量

    1. /**
    2. * Get请求 http://localhost:8080/get/login?name=tom&age=22
    3. * @param name
    4. * @param age
    5. * @return
    6. */
    7. @RequestMapping(value = "/get/login",method = RequestMethod.GET)
    8. public String get(@RequestParam String name,@RequestParam int age){
    9. logger.info(name);
    10. logger.info(""+age);
    11. return "SUCCESS";
    12. }
    13. /**
    14. * Get请求 http://localhost:8080/tom/12
    15. * @param name
    16. * @param age
    17. * @return
    18. */
    19. @RequestMapping(value = "/{name}/{age}",method = RequestMethod.GET)
    20. public String path(@PathVariable String name, @PathVariable int age){
    21. logger.info(name);
    22. logger.info(""+age);
    23. return "Good";
    24. }