从 post 请求正文中获取值

Fetch the values from the post request body

我想从 post 请求正文中获取两个值。我怎样才能在 JMeter 中做到这一点?

request-url: http://localhost:8080/webimpactclean/progress/createTrialUnits.do

POST data:
org.apache.struts.taglib.html.TOKEN=21b148643555da16dcd3ca2f32439b88&fakeSubmitButton=Submit&patientMonitoringFlagCopyDown=&enteredScreeningCopyDown=&enteredBaselineCopyDown=&enteredTreatmentCopyDown=&completedTreatmentCopyDown=&enteredFollowUpCopyDown=&completedFollowUpCopyDown=&create%5B0%5D=on&displayUnitNo%5B0%5D=1167&trialUnitReference%5B0%5D=PERFT1167&primaryInvestigatorShortNameDisabled%5B0%5D=&primaryInvestigatorShortName%5B0%5D=&primaryInvestigator%5B0%5D=&primaryCentreShortNameDisabled%5B0%5D=&primaryCentreShortName%5B0%5D=&primaryCentre%5B0%5D=&primaryCentreShortNameTemp%5B0%5D=&primaryCentreTemp%5B0%5D=&centreDepartmentName%5B0%5D=&centreName%5B0%5D=&centreLocationAddress%5B0%5D=&centreLocationAddressTemp%5B0%5D=&addressLine1%5B0%5D=&addressLine2%5B0%5D=&addressLine3%5B0%5D=&addressLine4%5B0%5D=

我想获取 displayUnitNo%5B0%5D=1167&trialUnitReference%5B0%5D=PERFT1167 值,即 1167PERFT1167

通常人们希望从 responses 中提取数据,从请求中提取数据没有任何意义,因为您应该已经有了这些数据。如果您想为每个 user/iteration 提供不同的数据 - 您应该 parameterize 请求正文。

无论如何,如果您想将请求中的值保存到 JMeter Variables you could do this using i.e. JSR223 PostProcessor 中,代码如下:

def parameters = sampler.getArguments().argumentsAsMap

vars.put('trialUnitReference', parameters.get('trialUnitReference[0]'))
vars.put('displayUnitNo', parameters.get('displayUnitNo[0]'))