1、jmeter获取请求参数,参数字段和参数值

import org.apache.jmeter.config.Arguments;
import java.util.Map.Entry;

Arguments args = sampler.getArguments();
Map map = args.getArgumentsAsMap();
log.info("==============:"+args.getClass().toString());
Iterator itor = map.entrySet().iterator();
while(itor.hasNext()){
	 Entry entry = (Entry) itor.next();
	 log.info("==========key:"+entry.getKey());  
}

2、

         a)获取http请求的 url

           String url = sampler.getPath();

         b)获取http请求的body内容           

           Arguments arguments = sampler.getArguments(); // 调用时注意sampler小写
          String body = arguments.getArgument(0).getValue();

           备注:需要引入包import org.apache.jmeter.config.Arguments;

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐