How to solve Chinese character garbled code in JMeter parameterization?

To solve the issue of Chinese character encoding in parameterization in JMeter, you can follow these steps:

  1. Open JMeter and select the request that needs to be parameterized.
  2. In the parametrization options of this request, change the value of the parameter from a fixed value to a variable (e.g. ${var}).
  3. In the test plan tree, select the “User Defined Variables” node, right-click and choose “Add” -> “Config Element” -> “User Defined Variables”.
  4. In the “User-defined Variables” configuration element, add the variables that need to be parameterized along with their corresponding values. Make sure that the values of the variables are correct Chinese characters and save using UTF-8 encoding.
  5. In the parameterization options, select the variables that need to be parameterized and set them to the corresponding variable name (for example: var).
  6. Execute the test plan to verify if the parametrized request displays the correct Chinese characters.

If the issue persists, you can try the following additional solutions to resolve the garbled text problem.

  1. Locate the jmeter.bat file (Windows) or jmeter file (Linux) in the bin directory of JMeter, and open it.
  2. Add the following content in the file, specify JVM parameters, and set JMeter to use UTF-8 encoding.
  3. – JVM_ARGS is being set to use UTF-8 file encoding.
  4. Save the file and restart JMeter.
  5. Re-run the test plan to verify if the parameterized requests correctly display Chinese characters.

If the above methods still cannot solve the problem of Chinese character encoding, it may be caused by other reasons. You can try adding a “Content-Type” field in the header information of the HTTP request and set it to “application/x-www-form-urlencoded;charset=UTF-8” to ensure the correct Chinese character set for the request and response.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds