注解

@PathVariable, @RequestHeader,@ModelAttribute,@RequestParam,@MatrixVariable,@CookieValue,@ResponseBody

<html><head><meta charset="UTF-8">
</head><body><ul><a href="car/3/owner/lisi?age=18&interests=basketball&interests=game">car/{id}/owner/{username}</a><li>@PathVariable(路径变量)</li><li>@RequestHeader(获取请求头)</li><li>@RequestParam(请求参数)</li><li>@CookieValue(获取Cookie值)</li><li>@RequestBody(获取请求体[POST])</li>
</ul><form action="/save" method="POST">测试@RequestBody获取数据<br/>用户名:<input name="username"/><br/>邮箱:  <input name="email"/></br><input type="submit" value="提交"></form><a href="/cars/sell;low=24;brand=byd,audi,yd">@MatrixVariable(矩阵变量)</a><br/>
<a href="/cars/sell;low=24;brand=byd;brand=audi;brand=yd">@MatrixVariable(矩阵变量)</a><br/>
<a href="/boss/1;age=20/2;age=10">@MatrixVariable(矩阵变量) /boss/{bossId}/{empId}</a><br/></body></html>
import org.springframework.web.bind.annotation.*;import javax.servlet.http.Cookie;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@RestController
public class ParameterTestController {@GetMapping("/car/{id}/owner/{username}")public Map<String, Object> getCar(@PathVariable("id") Integer id,@PathVariable("username") String name,@PathVariable Map<String, String> pv,@RequestHeader("User-Agent") String userAgent,@RequestHeader Map<String, String> heads,@RequestParam("age") Integer age,@RequestParam("interests") List<String> interests,@RequestParam Map<String, String> params//@CookieValue("_ga") Cookie cookie){Map<String, Object> map = new HashMap<>();map.put("id",id);map.put("name",name);map.put("pv",pv);map.put("userAgent",userAgent);map.put("heads",heads);map.put("age",age);map.put("interests",interests);map.put("params",params);//map.put("Cookie",cookie);return map;}@PostMapping("/save")public Map<String, Object> postMethod(@RequestBody String content){Map<String, Object> map = new HashMap<>();map.put("content",content);return map;}/** spring boot 默认禁用了矩阵变量的功能*   手动开启:原理. 对于路径的处理. UrlPathHelper类进行解析*               removeSemicolonContent(移除分号内容)支持矩阵变量*/@GetMapping("/cars/{path}")public Map carsSell(@MatrixVariable("low") String low,@MatrixVariable("brand") List<String> brand,@PathVariable("path") String path){Map<String, Object> map = new HashMap<>();map.put("low",low);map.put("brand",brand);map.put("path",path);return map;}@GetMapping("/boss/{bossId}/{empId}")public Map boss(@MatrixVariable(value = "age",pathVar = "bossId") Integer bage,@MatrixVariable(value = "age",pathVar = "empId") Integer eage,@PathVariable("bossId") String bossId,@PathVariable("empId") String empId){Map<String, Object> map = new HashMap<>();map.put("bage",bage);map.put("eage",eage);map.put("bossId",bossId);map.put("empId",empId);return map;}
}

矩阵变量的使用

Servlet API

复杂参数

自定义对象参数

1. handlerMapping中找到能处理请求的Handler

2. 为当前handler找一个适配器HandlerAdapter

参数解析器

确定将要执行的目标方法的每一个参数的值是什么

返回值处理器

springboot-web开发(请求参数)相关推荐

  1. SpringBoot - 获取Get请求参数详解

    利用 Spring Boot 来制作 Web 应用,就必定会涉及到前端与后台之间互相传递参数.下面演示 Controller 如何接收以 GET 方式传递过来的参数. 一.直接在请求路径中 (1).假 ...

  2. SpringBoot - 获取Get请求参数详解(附样例:非空、默认值、数组、对象)

    利用 Spring Boot 来制作 Web 应用,就必定会涉及到前端与后台之间互相传递参数.下面演示 Controller 如何接收以 GET 方式传递过来的参数. 一.参数直接在路径中 (1)假设 ...

  3. SpringBoot 获取 Get 请求参数详解

    叙述 利用 Spring Boot 来制作 Web 应用,就必定会涉及到前端与后台之间互相传递参数. 下面演示 Controller 如何接收以 GET 方式传递过来的参数. 解决方案 参数直接在路径 ...

  4. springboot获取URL请求参数的几种方法

    原文地址:http://www.cnblogs.com/xiaoxi/p/5695783.html 1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于pos ...

  5. springboot 处理put请求参数

    put请求参数理论上是在请求的body中(json传输),但是使用如下方式不能得到: @RequestParam Integer meetingId,@RequestParam Boolean pas ...

  6. SpringBoot关于@RequestBody请求参数

    一.Post请求中Dto参数带@RequestBody 方法代码: @PostMapping("/test")public UserDto getUserParam(@Reques ...

  7. springboot:web开发-Thymeleaf

    1.thymeleaf依赖 <dependency><groupId>org.thymeleaf</groupId><artifactId>thymel ...

  8. SpringBoot的GET请求参数包含[]等特殊符号,返回400状态码

    今天系统2.1版本上线时,忽然发现一个问题,通知公告模块中的一个文件不能下载了,而其他的是可以的,经过仔细的排查发现,是由于文件名中包含了英文的[],问题如下图: 原因分析 Tomcat的新版本中增加 ...

  9. springboot获取多个请求参数_springboot获取URL请求参数的多种方式

    1.直接把表单的参数写在Controller相应的方法的形参中,适用于get方式提交,不适用于post方式提交. /** * 1.直接把表单的参数写在Controller相应的方法的形参中 * @pa ...

最新文章

  1. H5 自动播放背景音频,兼容安卓和苹果手机, ios createInnerAudioContext 无法自动播放解决
  2. Py中re.sub学习【转载】
  3. 北京内推 | 地平线视觉算法团队招聘视觉算法实习生
  4. C#LeetCode刷题之#404-左叶子之和​​​​​​​​​​​​​​(Sum of Left Leaves)
  5. 删除变量PHP之session的使用
  6. C语言课后习题(21)
  7. 分布式应用中的一致性协议
  8. mysql开源内库_MySQL数据库(查询语句)
  9. jdialog 数据量大加载出现白板_王者荣耀:队友真的有人机?白板熟练进排位,资料面都是假的...
  10. 大学生在校期间可以考哪些证书?
  11. HDU2019 数列有序!【入门】
  12. php中 $_cfg,php 中 get_cfg_var() 与 ini_get() 的异同
  13. inno setup安装之前关闭mysql_inno setup 安装前判断进程是否存在,以及停止相应进程转...
  14. torch.utils.data
  15. macOS 开发 - Command Line Tool 命令行工具
  16. 百度2014移动研发笔试题目
  17. Android 电容屏和电阻屏
  18. 判断题 错与对的 t、f 是什么意思
  19. R 回归 虚拟变量na_R语言 | 回归分析(一)
  20. 误码率与信噪比的关系matlab,误码率BER与信噪比SNR的关系解析

热门文章

  1. 抓包工具Charles简单使用介绍(可抓取Android中app的请求)
  2. windows下pycharm远程调试pyspark
  3. 解析 this.initialize.apply(this, arguments)
  4. 静态程序分析chapter4 - 基于格(Lattice)理论的数据流分析
  5. 想要自学深度学习?不用GPU,浏览器就够了
  6. Centos:mysql的安装和使用:yum方式
  7. 1、Expect 远程登录linux系统
  8. Spring学习总结(18)——Spring整合Mysql数据库一主多从、多主多从配置
  9. RSA大会播报 – 2014最佳安全博客提名
  10. JS修改CSS的三种方式