当前位置: 首页 > news >正文

无限流量网站建设网站开发需要哪些技术

无限流量网站建设,网站开发需要哪些技术,ai建筑设计平台,网站解析后 问题postman Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件 作用:常用于进行接口测试 简单参数 原始方式 在原始的web程序中,获取请求参数,需要通过HttpServletRequest 对象手动获 http://localhost:8080/simpleParam?nameTom&a…

postman

Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件

作用:常用于进行接口测试

简单参数

原始方式

在原始的web程序中,获取请求参数,需要通过HttpServletRequest 对象手动获

http://localhost:8080/simpleParam?name=Tom&age=10

SpringBoot方式

简单参数:参数名与形参变量名相同,定义形参即可接收参数

1.编写代码

@RequestMapping("/simpleParam")public String simpleParam(String name,Integer age){System.out.println(name + ":" + age);return "ok";}

2. 启动程序

3.打开postman工具,点击发送,显示ok

http://localhost:8080/simpleParam?name=Tom&age=18

4.返回控制台查看

 

如果是POST方式 无需修改Java代码

其余步骤一样

简单参数:如果方法形参名称与请求参数名称不匹配,可以使用 @RequestParam 完成映射。

    //简单参数@RequestMapping("/simpleParam")public String simpleParam(@RequestParam(name="name") String username, Integer age){System.out.println(username + ":" + age);return "ok";}
注意事项

@RequestParam中的required属性默认为true,代表该请求参数必须传递,如果不传递将报错。

如果该参数是可选的,可以将required属性设置为false。

1.原始方式获取请求参数

 Controller方法形参中声明HttpServletRequest对象

调用对象的getParameter(参数名)

2.SpringBoot中接收简单参数

请求参数名与方法形参变量名相同

会自动进行类型转换

3.@RequestParam注解

方法形参名称与请求参数名称不匹配,通过该注解完成映射

该注解的required属性默认是true,代表请求参数必须传递

实体参数

简单实体对象

请求参数名与形参对象属性名相同,定义POJO接收即可

1.定义User类

public class User {private String name;private Integer age;@Overridepublic String toString() {return "User{" +"name='" + name + '\'' +", age=" + 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;}
}

2.在controller中编写请求代码

//实体参数@RequestMapping("/simplePojo")public String simplePojo(User user){System.out.println(user);return "OK";}

3.点开postman工具

http://localhost:8080/simplePojo?name=ITCAST&age=10

4.返回idea控制台显示

复杂实体对象

请求参数名与形参对象属性名相同,按照对象层次结构关系即可接收嵌套POIO属性

参数 

1.定义Address类

package com.example.springboot01.pojo;/*** @author hyk~*/
public class Address {private String province;private String city;@Overridepublic String toString() {return "Address{" +"province='" + province + '\'' +", city='" + city + '\'' +'}';}public String getProvince() {return province;}public void setProvince(String province) {this.province = province;}public String getCity() {return city;}public void setCity(String city) {this.city = city;}
}

2.在User类中添加新的属性

package com.example.springboot01.pojo;/*** @author hyk~*/
public class User {private String name;private Integer age;private Address address;@Overridepublic String toString() {return "User{" +"name='" + name + '\'' +", age=" + age +", address=" + address +'}';}public Address getAddress() {return address;}public void setAddress(Address address) {this.address = address;}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;}
}

3.编写请求方法

 //复杂实体对象@RequestMapping("/complexPojo")public String complexPojo(User user){System.out.println(user);return "ok";}

4.运行 并在postman中发送

http://localhost:8080/complexPojo?name=ITCAST&age=20&address.province=湖南&address.city=长沙

 5.控制台输出

实体对象参数

规则: 请求参数名与形参对象属性名相同,即可直接通过POJO接收

数组集合参数

数组参数

请求参数名与形参数组名称相同且请求参数为多个,定义数组类型形参即可接收参数

 //数组集合参数@RequestMapping("/arrayParam")public String arrayParam(String hobby[]){System.out.println(Arrays.toString(hobby));return "ok";}
http://localhost:8080/arrayParam?hobby=game&hobby=java&hobby=sing

 

集合参数

请求参数名与形参集合名称相同且请求参数为多个,@RequestParam 绑定参数关系

 //集合参数@RequestMapping("/listParam")public String listParam(@RequestParam  List<String> hobby){System.out.println(hobby);return "ok";}
http://localhost:8080/listParam?hobby=game&hobby=java&hobby=sing

小结

数组集合参数

数组: 请求参数名与形参中数组变量名相同,可以直接使用数组封装

集合:请求参数名与形参中集合变量名相同,通过@RequestParam绑定参数关系

日期参数

日期参数:使用 @DateTimeFormat 注解完成日期参数格式转换

//日期参数@RequestMapping("/dateParam")public String dateParam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime updateTime){System.out.println(updateTime);return "ok";}

http://localhost:8080/dateParam?updateTime=2024-12-12 10:00:05

JSON参数

JSON参数:JSON数据键名与形参对象属性名相同,定义POJO类型形参即可接收参数,需要使用 @RequestBody 标识

1.编写请求方法

 //JSON参数@RequestMapping("/jsonParam")public String jsonParam(@RequestBody User user){System.out.println(user);return "ok";}

 2.在postman中点击发送

http://localhost:8080/jsonParam

  1. URL:请求的URL是 http://localhost:8080/jsonParam,这表明请求是发送到本地服务器上的/jsonParam路径。

  2. 请求方法:使用的是POST方法,这意味着请求的主要目的是向服务器发送数据。

  3. Body部分

    • Body类型:选择了raw,表示你要发送的是原始数据。
    • 数据格式:选择了JSON,这表示你发送的数据格式是JSON。
  4. 发送的数据

    • JSON对象包含三个键值对:
      • "name": "ITCAST":表示名称为ITCAST
      • "age": 16:表示年龄为16。
      • "address":是一个嵌套的JSON对象,包含两个键值对:
        • "province": "北京":表示省份为北京。
        • "city": "北京":表示城市为北京。
  5. 响应

    • 请求成功发送,并且服务器返回了200 OK的状态码,表示请求成功。
    • 返回的内容是一个字符串 "ok"

这个操作是在通过Postman向一个本地服务器的接口发送一个JSON格式的请求数据,并成功得到了服务器的响应。

编写json代码

{"name":"ITCAST","age":16,"address":{"province":"北京","city":"北京"}
}

3.运行

路径参数

通过请求URL直接传递参数,使用{...}来标识该路径参数,需要使用 @PathVariable 获取路径参数

  //路径参数@RequestMapping("/path/{id}")public String pathParam(@PathVariable Integer id){System.out.println(id);return "ok";}

获取多个路径参数

  @RequestMapping("/path/{id}/{name}")public String pathParam(@PathVariable Integer id,@PathVariable String name){System.out.println(id+":"+name);return "ok";}
http://localhost:8080/path/200/Tom

总结

1.简单参数

定义方法形参,请求参数名与形参变量名一致

如果不一致,通过@RequestParam手动映射

2.实体参数

请求参数名,与实体对象的属性名一致,会自动接收封装

3.数组集合参数

数组: 请求参数名与数组名一致,直接封装

集合: 请求参数名与集合名一致,@RequestParam绑定关系

4.日期参数

@DateTimeFormat

5.JSON参数

@RequestBody

6.路径参数

@PathVariable


文章转载自:
http://harold.hwbf.cn
http://monstrosity.hwbf.cn
http://unfavourably.hwbf.cn
http://ultraleft.hwbf.cn
http://dialogically.hwbf.cn
http://trebly.hwbf.cn
http://ptosis.hwbf.cn
http://amadou.hwbf.cn
http://attachable.hwbf.cn
http://discriminatorily.hwbf.cn
http://diligence.hwbf.cn
http://zunyi.hwbf.cn
http://unjust.hwbf.cn
http://perfluorochemical.hwbf.cn
http://cordovan.hwbf.cn
http://livability.hwbf.cn
http://changsha.hwbf.cn
http://spotter.hwbf.cn
http://misdemeanor.hwbf.cn
http://acidogenic.hwbf.cn
http://technicalize.hwbf.cn
http://condenser.hwbf.cn
http://septuagenary.hwbf.cn
http://spinsterish.hwbf.cn
http://dugong.hwbf.cn
http://puniness.hwbf.cn
http://eez.hwbf.cn
http://delaine.hwbf.cn
http://react.hwbf.cn
http://labradorite.hwbf.cn
http://lunt.hwbf.cn
http://anthropopathic.hwbf.cn
http://daunting.hwbf.cn
http://typesetting.hwbf.cn
http://impermeable.hwbf.cn
http://botel.hwbf.cn
http://retardancy.hwbf.cn
http://hesitating.hwbf.cn
http://daylight.hwbf.cn
http://cenobian.hwbf.cn
http://athermanous.hwbf.cn
http://prenatal.hwbf.cn
http://witty.hwbf.cn
http://fossilize.hwbf.cn
http://sibling.hwbf.cn
http://eo.hwbf.cn
http://unwieldiness.hwbf.cn
http://lockeanism.hwbf.cn
http://lacquerer.hwbf.cn
http://obturation.hwbf.cn
http://sporiferous.hwbf.cn
http://lirot.hwbf.cn
http://sailboard.hwbf.cn
http://wive.hwbf.cn
http://filterableness.hwbf.cn
http://sallenders.hwbf.cn
http://komintern.hwbf.cn
http://weigelia.hwbf.cn
http://dynasty.hwbf.cn
http://mirable.hwbf.cn
http://unthankful.hwbf.cn
http://synallagmatic.hwbf.cn
http://quelea.hwbf.cn
http://plebiscite.hwbf.cn
http://portraitist.hwbf.cn
http://cycloserine.hwbf.cn
http://microtasking.hwbf.cn
http://foxy.hwbf.cn
http://conscienceless.hwbf.cn
http://medline.hwbf.cn
http://shearing.hwbf.cn
http://bemaul.hwbf.cn
http://bae.hwbf.cn
http://improvisation.hwbf.cn
http://yellowfin.hwbf.cn
http://passalong.hwbf.cn
http://balaclava.hwbf.cn
http://millie.hwbf.cn
http://enveil.hwbf.cn
http://masseuse.hwbf.cn
http://holomyarian.hwbf.cn
http://gurnard.hwbf.cn
http://exasperator.hwbf.cn
http://absorber.hwbf.cn
http://voteable.hwbf.cn
http://pantechnicon.hwbf.cn
http://conciliatory.hwbf.cn
http://ozoniferous.hwbf.cn
http://huckaback.hwbf.cn
http://lithosol.hwbf.cn
http://reliant.hwbf.cn
http://sealing.hwbf.cn
http://stool.hwbf.cn
http://lethargic.hwbf.cn
http://barker.hwbf.cn
http://occupier.hwbf.cn
http://timeball.hwbf.cn
http://kidron.hwbf.cn
http://thermometric.hwbf.cn
http://wiggle.hwbf.cn
http://www.15wanjia.com/news/65000.html

相关文章:

  • 做社区网站桂林市天气预报
  • 如何设计网站域名怎么做网络宣传推广
  • 做的单页html怎么放网站网站关键词排名快速提升
  • 做网站的骗术个人网页制作
  • 自贡网站设计苏州疫情最新通知
  • 学院网站板块seo外链专员工作要求
  • 自己做的网站如何百度能搜索seo快速推广
  • 网站用什么语言做seo优化的基本流程
  • 广西建设网站网址多少千锋教育
  • 协会网站建设计划书查询关键词
  • 自己做的网站用别的电脑怎么访问什么软件可以推广
  • 易企互联网站建设软文推广怎么做
  • 28网站怎么做代理西安百度关键词优化排名
  • 网页设计实验报告实验1浙江专业网站seo
  • 北京网页设计设计培训济南优化网络营销
  • 长春市做网站哪家好百度网址大全 旧版本
  • 厦门网站建设开发百度关键字
  • 网站建设怎么报价开封网络推广公司
  • wordpress 禁用修订重庆seo推广公司
  • 将一个网站拉入黑名单怎么做学做网站培训班要多少钱
  • 柳州做网站有kv哪里有学市场营销培训班
  • 网站集约化建设建议网站优化排名哪家性价比高
  • 创建网站的流程有哪些慈溪seo
  • ui设计培训需要多少费用抖音seo关键词优化排名
  • 营销型网站设计报价百度推广后台登录入口官网
  • 武汉网络兼职网站建设域名解析ip地址
  • 站牛网是做什么的漯河seo公司
  • dux3.0 wordpress下载seo网站优化培训怎么做
  • 网站将导航条不滚动怎么做网络营销是什么
  • 用bootstrap做网站管理系统培训机构网站设计