• @pathvariable和@RequestParam的区别


    @PathVariable 获取的是请求路径url中的值: (http://xxx.xxx.com/get_10.html,侧重于请求的URL路径里面的{xx}变量 )
    //获取url中某部分的值 @RequestMapping("get_{id}")//获取到 10 

    public String get(@PathVariable Integer id, Model model) {}

    //测试例子 http://hcss:8090/hi1/aa bb/cc
    @RequestMapping("/hi1/{a1}{a2}/{a3}")
    public String showIndex1 (Model model, @PathVariable String a1,@PathVariable String a2,@PathVariable String a3,String a4) {}
    //测试结果:
    a1=aa bb a2="" a3="a3" a4=null
    @RequestParam 获取的是url中问号后面的请求参数的值:http://localhost:8080/Springmvc/user/page.do?pageSize=3&pageNow=2
    //获取pageSize和pageNow的值: 
    @RequestMapping("page") public String page(@RequestParam int pageSize,@RequestParam int pageNow){}
  • 相关阅读:
    MySQL经典练习题(四)
    MySQL经典练习题(三)
    MySQL经典练习题(二)
    MySQL经典练习题(一)
    MySQL经典练习题-数据准备
    表连接
    子查询
    MySQL中函数分类
    排序
    数据分组
  • 原文地址:https://www.cnblogs.com/hongchengshise/p/10513948.html
Copyright © 2020-2023  润新知