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、
-
sampler (是Samper对象) 参考http://jmeter.apache.org/api/org/apache/jmeter/samplers/Sampler.html
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;