简体   繁体   English

JSR223 预处理器中变量的 JMeter 问题

[英]JMeter Problem with the variable in JSR223 PreProcessor

I send POST request with the following JSON in body data我在正文数据中使用以下 JSON 发送 POST 请求

在此处输入图片说明

The problem is that the unixTimeValue variable is not setting问题是 unixTimeValue 变量没有设置

This is how my JSR223 PreProcessor looks like这就是我的 JSR223 预处理器的样子在此处输入图片说明 \\ \\

vars保存字符串值,您可以在放置值时转换双精度值:

vars.put("unixTimeValue", String.valueOf(a));
  1. You can change your lines 1-14 to:您可以将第 1-14 行更改为:

     vars.put("RANDOM_STRING", org.apache.commons.lang.RandomStringUtils.randomAscii(12))

    See RandomStringUtils class JavaDoc for more potentially useful functions有关更多潜在有用的功能,请参阅RandomStringUtils 类 JavaDoc

  2. Change your line 20 to:将第 20 行更改为:

     vars.putObject("unixTimeValue", sin);

    as vars.put() function accepts only Strings while vars.putObject() accepts pretty much everything, see JMeterVariables class JavaDoc for more details由于vars.put()函数只接受字符串,而vars.putObject()接受几乎所有内容,有关更多详细信息,请参阅JMeterVariables 类 JavaDoc

  3. Since JMeter 3.1 you should be using Groovy language for scripting mainly because Groovy has much better performance comparing to Beanshell, see Apache Groovy - Why and How You Should Use It article for comprehensive explanation with examples 从 JMeter 3.1 开始,您应该使用 Groovy 语言编写脚本,主要是因为与 Beanshell 相比,Groovy 具有更好的性能,请参阅Apache Groovy - Why and How You Should Use It文章以通过示例进行全面说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM