jmeter使用过程中需要在对body的内容进行加密处理,比如md5加密方式或者sha256等等,需要获取body的内容然后再进行加密
获取body,例如请求的body为
{ "msgId": "${msgId}", "orderNum": "${orderNum}", "termId": "${termId}", "transAmt": "${transAmt}", "transCurrency": "${transCurrency}", "merTransTime": "${merTransTime}", "clientVer": "", "goodsInfo": "", "scanCodeId": "${scanCodeId}", "TradeFrom": "${TradeFrom}" }
首先需要导入
import org.apache.jmeter.config.Arguments;
具体代码如下:
import org.apache.jmeter.config.Arguments; Arguments args = sampler.getArguments(); Map reqMap = args.getArgumentsAsMap(); for (String key : reqMap.keySet()) { log.info(reqMap.get(key)); }
通过查看日志展示,打印的body信息