当前位置:网站首页>jmeter将上一个请求的结果作为下一个请求的参数
jmeter将上一个请求的结果作为下一个请求的参数
2022-06-27 03:01:00 【小han的日常】
因项目接口需要发送请求是需要附带token值,故整理本文介绍jmeter中将上一个请求的结果作为下一个请求的参数的操作方法。
1、新建线程组;在线程组下新建HTTP请求来获取token;新建察看结果树查看接口请求状态;



2、 完成【HTTP请求】设置,发送请求,查看【察看结果树】页面的响应数据;

格式化后如下

3、 在【察看结果树】页面下进行正则表达式测试,如上图,我们想要得到的数据是{ "data":"我们想要的token"}

4、 使用正则表达式提取到想要的内容
"data":"(.+?)"
():其中括起来的这部分就是要提取的
.:一个点表示匹配除“\n”之外的任何单个字符。(\n表示换行符)
+:+号表示匹配前一个字符,1次或者多次(此处填*也可以)
?:表示非贪婪模式,找到一个匹配的数据就停止;贪婪模式,去掉?号就可以,表示将所有符合的数据都提取出来
Match count: 1 ---表示符合添加的有一个值
Match[1][1] = xxxxxxxxx ---表示取到的第一个值是xxxxxx
如存在取到多个值时,表达方式如下
Match[2][1] = -----取到的第二个值
Match[3][1] = -----取到的第三个值5、添加【后置处理器】--【正则表达式提取器】


引用名称: 是下个请求将要引用到的自定义变量名;
正则表达式: 是提取你想要内容的正则表达式,可以结合 察看结果树 下的 正则测试 编写;
模板: 是使用提取到的第几个值。因为可能有多个值匹配,所以要使用模板。从 1 开始匹配,依次类推。这里只有一个,所以填写 $1$ 即可;根据 察看结果树 下的 正则测试 返回的Match值填写
匹配数字(0代表随机): 0 代表随机取值,1 代表全部取值。这里只有一个,填 1 即可;
缺省值: 表示参数没有取到值的话,给它的值。一般不填或填null6、新添加【HTTP请求】(需要token),来进行验证

7、完成http请求页面内容的填写后,添加【HTTP信息头管理器】来添加token


8、新建查看结果树运行线程,查看结果

已成功将 获取token接口中的token进行使用
-------------
本文暂不提供 正则表达式提取器需要提取多个值的情况,后续整理
边栏推荐
- Press key to control LED status reversal
- How do I simplify the development of interfaces in open source systems?
- 对数器
- PAT甲级 1025 PAT Ranking
- 正则表达式:语法
- Detailed explanation of ThreadLocal
- H5 liquid animation JS special effect code
- 1. Project preparation and creation
- Yuantou firm offer weekly record 20220627
- Hot discussion: what are you doing for a meaningless job with a monthly salary of 18000?
猜你喜欢

Uni app's uparse rich text parsing perfectly parses rich text!
![[micro service sentinel] degradation rules slow call proportion abnormal proportion abnormal constant](/img/4d/4d4424b609a3c0cd36c5c79daa8861.png)
[micro service sentinel] degradation rules slow call proportion abnormal proportion abnormal constant

"All majors are persuading them to quit." is it actually the most friendly to college students?

Pat grade a 1019 general palindromic number

Record the method of reading excel provided by unity and the solution to some pits encountered

Cvpr2022 | pointdistiller: structured knowledge distillation for efficient and compact 3D detection

Learning Tai Chi Maker - mqtt Chapter 2 (II) esp8266 QoS application

PAT甲级 1021 Deepest Root

Window 加密壳实现

学习太极创客 — MQTT(六)ESP8266 发布 MQTT 消息
随机推荐
455. distribute biscuits [distribution questions]
Installing the Damon database using the command line
Don't be brainwashed. This is the truth about the wages of 90% of Chinese people
记录unity 自带读取excel的方法和遇到的一些坑的解决办法
Pat grade a 1019 general palindromic number
Crowd simulation
2022年氯碱电解工艺试题及答案
Mmdetection uses yolox to train its own coco data set
Questions and answers of chlor alkali electrolysis process in 2022
一文教你Kali信息收集
Oracle/PLSQL: Ltrim Function
Qingscan use
Learning Tai Chi Maker - mqtt (VII) advanced mqtt theme
Is the division of each capability domain of Dama, dcmm and other data management frameworks reasonable? Is there internal logic?
Super detailed, 20000 word detailed explanation, thoroughly understand es!
Flink学习1:简介
I found a JSON visualization tool artifact. I love it!
Constraintlayout Development Guide
Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
Flink学习2:应用场景