在没有 精确或模糊查询的接口时可以使用jmeter 获取指定的值的ID
1 1 import java.lang.String ; 2 2 String getTargetName="iphone632g"; 3 3 //判读相应结果中是否包含指定值:iphone632g 4 4 boolean containsCategory=prev.getResponseDataAsString().contains(getTargetName); 5 5 vars.putObject("containsCategory",containsCategory); 6 6 if(containsCategory){ 7 7 String [] categoryNameSplit="${categoryName_ALL}".split(",") ; 8 8 String [] categoryIDSplit = "${categoryID_ALL}".split(","); 9 9 for (int i=0 ; i<categoryNameSplit.length ;i++ ) { 1010 //假如找到指定的分类就将该分类的id put 到变量中去 ; 1111 if (categoryNameSplit[i].equals(getTargetName)) { 1212 log.info("i=========="+String.valueOf(i)); 1313 log.info("categoryIDSplit["+i+"]="+categoryIDSplit[i]); 1414 vars.put("categoryId",categoryIDSplit[i]); 1515 break ; 1616 } 1717 } 1818 } 1919 20 21 1 log.info("${__jexl2(${mobilePhone}*2+4,)}"); 22 2 int a=${__jexl2(3*2+4,)}; 23 3 Integer b=${__jexl2(3*2+4,)}+${__jexl2(3*2+4,)}; 24 4 Integer b1=${__jexl2(${pim_interfaceType}+${pim_interfaceType})}; 25 5 log.info("b1=="+b1); 26 6 //${__jexl2(,)}+${__jexl2(,)} 返回结果可以是String 类型 或者 Integer 类型; 27 7 String value ="${__jexl2(3*2+4,)}+${__jexl2(3*2+4,)}" ; 28 8 log.info("value="+value); 29 9 //String + Integer 3010 String value1 ="${__jexl2(3*2+4,)}"+${__jexl2(3*2+4,)} ; 3111 log.info("value1="+value1); 3212 Integer createOrderAfterlockQty3=Integer.parseInt("1")+${__jexl2(${quantity})}; 3313 log.info("xxxxxxxxxxxxxxx=="+createOrderAfterlockQty3); 3414 String concatItemId="\""+"${itemId_all}".replace(",", "\",\"")+"\"" ; 3515 log.info("concatItemId="+concatItemId);