【问题标题】:JMeter: java.net.URISyntaxException: Malformed escape pair at indexJMeter:java.net.URISyntaxException:索引处格式错误的转义对
【发布时间】:2016-01-16 08:18:22
【问题描述】:

我在 JMeter 中重新编写用户搜索记录的场景,一旦列出结果,单击 Excel 图标以下载 .xls 中的结果,但在记录时单击“Excel”图标时显示以下错误。

java.net.URISyntaxException: Malformed escape pair at index 336: https://mylink.myURL.com/Change/ExportHandler?objChanger=ANK,All%20Products,A,Jan-2015,Jan-2016,Country,India,,,1&tableName=datatable-example5&iSortCol_0=2&sSortDir_0=desc&aoColumns=Name,Salesa,Salesb,Share,&Header=Name,ABC%20FM%20Gross%20Sales%20(lakhs),Industry%20Gross%20Sales%20(lakhs),share%20share%20(%),
	at java.net.URI$Parser.fail(Unknown Source)
	at java.net.URI$Parser.scanEscape(Unknown Source)
	at java.net.URI$Parser.scan(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:286)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
	at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
	at org.apache.jmeter.protocol.http.proxy.Proxy.run(Proxy.java:240)

谷歌上的解决方案是在 URL 中用 25 替换 %,有人可以帮我解决这个问题,就像我如何对 url 进行编码一样。

谢谢!

【问题讨论】:

    标签: java excel url jmeter encode


    【解决方案1】:

    JMeter 提供__urlEncode() 函数,旨在转义 URL 中不允许的特殊字符。

    您可以使用菜单 -> 选项中的Function Helper Dialog 来确保使用正确的语法

    有关此功能和其他有用的 JMeter 功能的全面信息,请参阅 How to Use JMeter Functions 系列帖子。

    【讨论】:

      【解决方案2】:

      试试这个

      String escapedUrl = url.replaceAll("(?i)%(?![\\da-f]{2})", "%25");
      

      【讨论】:

      • 我在哪里可以提到这个?
      猜你喜欢
      • 2018-04-24
      • 2018-07-24
      • 1970-01-01
      • 2015-12-04
      • 2011-03-26
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多