April 27, 2020
Estimated Post Reading Time ~

How to handle the request parameter encoding(charset) in AEM

Sometimes we may need to change the default parameter encoding in Adobe Experience Manager(AEM) to handle different language characters.

This post explains the approach to change the encoding for AEM request parameters.

Apache Sling Request Parameter Handling:
The request parameter encoding can be changed through the following configuration - "Apache Sling Request Parameter Handling"

Change the value of "Default Parameter Encoding" to required values - e.g UTF-8/ISO-8859-1 (default value is ISO-8859-1)



This is a global configuration and it will change the parameter encoding for all the incoming requests.

Change the encoding for specific form:
The below steps can be followed to change the encoding for specific form

Add the parameter "_charset_" as a hidden field with required encoding value inside the form.

<form role="form" id="test" action="xxxxx" method="POST" accept-charset="ISO-8859-1" onsubmit="document.charset = 'ISO-8859-1'">
<input type="hidden" id="_charset_" name="_charset_" value="ISO-8859-1"/>
........
........
</form>

accept-charset="ISO-8859-1"(non IE browsers), onsubmit="document.charset = 'ISO-8859-1'"(Configuration for IE browser) - This configuration specify the encoding that is to be used for the form submission.

This will change the encoding of this particular form. The different encoding can be specified page level and form level only to handle the data.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.