栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringMVC--restFul风格

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringMVC--restFul风格

restFul风格 restFul风格 传统get方式提交
  • url1: http://localhost:8080/findUser?name=tomcat&age=18
  • url2: http://localhost:8080/findUser?name=tomcat&age=18&sex=男

需求: 上述的参数传递是否可以简化!
简化写法:

  • url3: http://localhost:8080/findUser/tomcat/18/男
restFul风格说明 案例: url3: http://localhost:8080/findUser/tomcat/18/男 (发送)

要求:

  1. restFul的风格数据的位置一旦确定,不能修改.
  2. 参数与参数之间使用"/"的方式分割.
  3. restFul的风格适用于 get/post/put/delete 请求类型

请求类型种类: get/post/put/delete

编辑controllee类
  
    @RequestMapping("/findUser/{name}/{age}/{sex}")
    public String findUser(@PathVariable String name,
                           @PathVariable int age,
                           @PathVariable String sex){

        return name+":"+age+":"+sex;
    }

效果

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/644223.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号