zoukankan      html  css  js  c++  java
  • @RequestMapping参数value和params的区别

    value的值可以是一个url地址的形式或者正则表达式或者rest风格的形式,而params正如其名是参数,访问的时候params的值只能作为参数,不能作为访问的地址,请看下例>

    value的使用

        @RequestMapping(value="list",method=RequestMethod.GET)
        public String getEmployeeData(ModelAndView mav,HttpServletRequest request,HttpServletResponse response){
            System.out.println("============");
            return "test";
        }

    访问的地址可以是/xx项目名/xxcontroller名/list

    params的使用

    @RequestMapping(value="list",params="one",method=RequestMethod.GET)
        public String getEmployeeData(ModelAndView mav,HttpServletRequest request,HttpServletResponse response){
            System.out.println("============");
            return "test";
        }

    这种方式如果两个方法的value值相同,只需要加上参数one即可区别,访问的地址为/xx项目名/xxcontroller名/list?one

    或者

    @RequestMapping(params="list",method=RequestMethod.GET)
        public String getEmployeeData(ModelAndView mav,HttpServletRequest request,HttpServletResponse response){
            System.out.println("============");
            return "test";
        }

    这种方式要访问该方法的地址为:/xx项目名/xxcontroller名?list,没错,这里没有方法名,list只是参数。

  • 相关阅读:
    csuoj-1004-Xi and Bo
    csuoj-1003-UC Browser
    网络命令
    linux网络配置
    java面向对象
    java类 面向对象
    java方法 Scanner、Random类
    java集合
    java数组
    java流程控制语句
  • 原文地址:https://www.cnblogs.com/yxjdragon/p/5986935.html
Copyright © 2011-2022 走看看