JMeter密码中@字符转义异常致登录失败,求CSV传参解决方案
Hey there, I’ve dealt with this exact special character encoding issue in JMeter before, so let’s get your CSV-based password working without switching to Body Data. Here’s what’s happening and how to fix it:
Why this happens
JMeter automatically applies URL encoding to parameter values by default. Characters like @ get converted to %40 (their URL-encoded equivalent), but your login system expects the raw @ character (since it works when you paste the password directly into Body Data).
Fix 1: Disable URL encoding for the password parameter
This is the simplest and most direct solution:
- Open your HTTP Request sampler where you’re sending the login credentials.
- Go to the Parameters section (the same area where you see your username and password fields from the recording).
- Find the row for your password parameter. You’ll see an Encode checkbox at the end of the row—it’s probably checked by default.
- Uncheck this checkbox. This tells JMeter to send the password value exactly as it’s read from your CSV file, without encoding the
@character.
Fix 2: Use the __urldecode function (if Fix 1 doesn’t work)
If for some reason you can’t disable the Encode checkbox (or if JMeter is still encoding the value), you can force-decode the password variable:
- In the password parameter’s value field, replace
${your_password_variable}with${__urldecode(${your_password_variable})}. - This function will reverse any URL encoding applied to the password, turning
%40back into@before sending the request.
Quick checks to ensure your CSV is set up correctly
- Double-check your CSV Data Set Config: Make sure the variable names match the ones you’re using in the HTTP Request (e.g., if your CSV has columns
username,password, set the variable names tousername,password). - Ensure your CSV file doesn’t have extra quotes or formatting around the password unless you’ve enabled the Allow quoted data option in the CSV Data Set Config (you shouldn’t need this for
@, but it’s good to verify).
Verify the fix
Run your script and use the View Results Tree listener to check the request details. Look at the Parameters tab—your password should show up with the raw @ character, not %40. If that’s the case, your login should succeed just like it did with Body Data.
内容的提问来源于stack exchange,提问作者Lakshmikanth

