foreach控制器一般是和用户参数一块使用,循环拿参数,每次参数都不一样。
1、添加foreach控制器

2、添加用户自定义变量

3、用户参数配置
此处参数配置是有要求的,需要时xxx_xx方便管理和运行,如url_1、url_2或者aa_1、aa_2如下图。

4、配置foreach参数
上文提到的参数配置,在下图的“输入变量前缀”对应,上文中参数是aaa开头,这里必须是aaa

5、在foreach下添加http请求和监听


6、测试结果

如果报错如下
java.net.URISyntaxException: Expected closing bracket for IPv6 address at index 22: http://[127.0.0.1:8888/hello.do]/
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.failExpecting(URI.java:2854)
at java.net.URI$Parser.parseServer(URI.java:3231)
at java.net.URI$Parser.parseAuthority(URI.java:3155)
at java.net.URI$Parser.parseHierarchical(URI.java:3097)
at java.net.URI$Parser.parse(URI.java:3053)
at java.net.URI.<init>(URI.java:588)
at java.net.URL.toURI(URL.java:946)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:548)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.lang.Thread.run(Thread.java:748)
是因为你的步骤3中的变量值中含有“:”.
网友评论