SpringBoot中如何接收请求参数

这篇文章将为大家详细讲解有关SpringBoot中如何接收请求参数,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联是网站建设技术企业,为成都企业提供专业的网站设计、成都网站制作,网站设计,网站制作,网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制适合企业的网站。十多年品质,值得信赖!

application/json接收

/**  * 参数不可为空,可为{} * userDto中的属性 非必填  */@RequestMapping("/hello5") public String hello5(@RequestBody UserDto userDto) {   return userDto.getName() + "," \+ userDto.getAge(); }

x-www-form-urlencoded、?拼接、form-data接收

@RequestMapping("/hello1") public String hello1(@RequestParam("name") String name) {   return name; }  @RequestMapping("/hello2") public UserDto hello2(@RequestHeader("name") String name, @RequestHeader("age") Integer age) {   return new UserDto(name, age); }  /**  * @param name 非必填  */@RequestMapping("/hello3") public String hello3(String name) {   return name; }  /**  * userDto中的属性 非必填  */@RequestMapping("/hello4") public String hello4(UserDto userDto) {   return userDto.getName() + "," \+ userDto.getAge(); }

UserDto

public class UserDto {    private String name;    private Integer age;    public String getName() {     return name;   }    public void setName(String name) {     this.name = name;   }    public Integer getAge() {     return age;   }    public void setAge(Integer age) {     this.age = age;   } }

关于SpringBoot中如何接收请求参数就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


网站标题:SpringBoot中如何接收请求参数
文章路径:http://bzwzjz.com/article/gossej.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 网站设计 营销网站建设 成都网站建设 成都网站制作 成都响应式网站建设公司 高端网站建设 企业网站设计 网站制作 成都网站设计 高端网站设计推广 定制网站建设 成都品牌网站建设 成都网站建设公司 专业网站设计 网站制作 手机网站制作 成都企业网站建设 重庆手机网站建设 高端品牌网站建设 定制网站制作 成都网站建设 外贸营销网站建设