JMeter中验证参数空格时,要勾选编码

问题:在jmeter中测试接口,验证一个传入参数对空格的处理时,运行报错

报错信息

java.net.URISyntaxException: Illegal character in query at index 130: http://api.t4.2012iot.com/api-devicemanage/device/addDevice?sn=22222222222222222222222222222222222222222222222222&type=5&phone=111 111&camType=&brand=&password=
    at java.net.URI$Parser.fail(Unknown Source)
    at java.net.URI$Parser.checkChars(Unknown Source)
    at java.net.URI$Parser.parseHierarchical(Unknown Source)
    at java.net.URI$Parser.parse(Unknown Source)
    at java.net.URI.<init>(Unknown Source)
    at java.net.URL.toURI(Unknown Source)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:535)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1282)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1271)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:627)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:551)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:490)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
    at java.lang.Thread.run(Unknown Source)

问题原因:在jmeter中如果要验证某个传参是否支持空格时, 必须在勾选编码,这样空格字符才能被用+号代替作为空格在请求的url中使用

 

posted @ 2020-05-15 11:45  木头人11  阅读(1299)  评论(0编辑  收藏  举报