<div id="article_content" class="article_content clearfix">
<div class="article-source-link">
原文链接:<a href="http://www.cnblogs.com/landhu/p/8980195.html" target="_blank" rel="noopener">http://www.cnblogs.com/landhu/p/8980195.html</a>
</div>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-3019150162.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-3019150162.css">
<div class="htmledit_views" id="content_views">
<div id="cnblogs_post_body" class="blogpost-body"><p> 好吧,最近还是在折腾Jmeter,在一个post请求中,发现啃爹的竟然带有特殊字符:'</p>
<p> 怎么办,直接将数据写入,如下:</p>
<p> <img src="https://images2018.cnblogs.com/blog/835259/201805/835259-20180502143503905-1211945429.png" alt=""></p>
<p>然后在实际用post发请求时,jmeter自动给转义了,如下:</p>
<div class="cnblogs_Highlighter">
<pre><code class="language-csharp hljs">xxxx=%<span class="hljs-number">27</span>qq%<span class="hljs-number">27</span>%<span class="hljs-number">3</span>A%<span class="hljs-number">2720</span>%<span class="hljs-number">27</span>&rrr=%<span class="hljs-number">7</span>Bqq%<span class="hljs-number">27</span>
</code><div class="hljs-button {2}" data-title="复制" οnclick="hljs.copyCode(event)"></div></pre>
</div>
<p> 怎么办???那就加加转义字符试试,与是,加了"\",“\\”,“\\\”,“\\\\”都没用</p>
<p> </p>
<p>只能换方法了</p>
<p>这时,几年前写的jmter<a href="http://www.cnblogs.com/landhu/p/5484698.html" rel="nofollow" data-token="c44b2996c77e2ce006e73cfba007a02f">请求客户端发送机制</a>回到脑海,又重读了一遍</p>
<p>我们将Implementation换成Java的方式来试一试</p>
<p><img src="https://images2018.cnblogs.com/blog/835259/201805/835259-20180502144122547-1489175979.png" alt=""></p>
<p>结果终于发现,符号' 没有转义,正常发出</p>
<div class="cnblogs_Highlighter">
<pre><code class="language-csharp hljs"><ol class="hljs-ln"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">POST data:</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">xxxx=<span class="hljs-string">'qq'</span>:<span class="hljs-string">'20'</span>&rrr={<span class="hljs-string">'qq'</span>:<span class="hljs-string">'233'</span>}</div></div></li></ol></code><div class="hljs-button {2}" data-title="复制" οnclick="hljs.copyCode(event)"></div></pre>
</div>
<p> </p>
<p>原来,默认的HTTPClinet在POST时会自动将特殊字符转义,然而Java在发送过程中却未处理。</p></div>
<p>转载于:https://www.cnblogs.com/landhu/p/8980195.html</p> </div>
</div>
jmeter 中 Client implementation HttpClient4和java区别实践一
最新推荐文章于 2022-08-09 15:09:59 发布