Jmeter -如何在Jmeter中将%转义为特殊字符

uxh89sit  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(498)

我有一个脚本,在我的请求中,我使用:

"requirements": [
    {
      "key": "SITEID",
      "operand": "%",
      "value": "1,202,209"
    }
  ]

我遇到了一些例外:

java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: "","
    at java.net.URLDecoder.decode(URLDecoder.java:232) ~[?:?]
    at java.net.URLDecoder.decode(URLDecoder.java:142) ~[?:?]
    at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.decodeQuery(RequestViewHTTP.java:336) ~[ApacheJMeter_http.jar:5.4.3]
    at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.getQueryMap(RequestViewHTTP.java:290) ~[ApacheJMeter_http.jar:5.4.3]
    at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.setSamplerResult(RequestViewHTTP.java:216) ~[ApacheJMeter_http.jar:5.4.3]
    at org.apache.jmeter.visualizers.RequestPanel.setSamplerResult(RequestPanel.java:116) ~[ApacheJMeter_components.jar:5.4.3]
    at org.apache.jmeter.visualizers.SamplerResultTab.setupTabPane(SamplerResultTab.java:238) ~[ApacheJMeter_components.jar:5.4.3]
    at org.apache.jmeter.visualizers.ViewResultsFullVisualizer.valueChanged(ViewResultsFullVisualizer.java:385) ~[ApacheJMeter_components.jar:5.4.3]
    at org.apache.jmeter.visualizers.ViewResultsFullVisualizer.valueChanged(ViewResultsFullVisualizer.java:363) ~[ApacheJMeter_components.jar:5.4.3]
    at javax.swing.JTree.fireValueChanged(JTree.java:2967) ~[?:?]
    at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3456) ~[?:?]

为了避开%符号,应该做些什么?

tjvv9vkg

tjvv9vkg1#

1.如果您使用“参数”部分-勾选“URL编码”框

1.如果您直接将JSON添加到URL-将其 Package 到__urlencode()函数中,如下所示:

${__urlencode({"requirements":[{"key":"SITEID"\,"operand":"%"\,"value":"1\,202\,209"}]})}

1.请确保您确实需要使用HTTP GET方法,因为请求主体看起来更像是POST方法
1.您可能还需要添加一个HTTP Header Manager,并将其配置为发送值为application/jsonContent-Type标头

相关问题