AEM/CQ5 Request Parameter not UTF-8

拈花ヽ惹草 提交于 2019-12-08 01:54:38

问题


Have a slight issue with AEM 6.0 SP1 and the search component. If searching for a french word like "Français" the "ç" gets messed up

the query string is like ?q=Français on the JSP side, request.getCharacterEncoding() returns ISO-8859-1 instead of UTF-8 like we need.

I know that when under tomcat you can change the URIEncoding at the connector level.

But for an AEM/CQ instance running directly by itself, there is no such thing. Anyone figured this out?


回答1:


For 5.6.1 : The default encoding can be set in the configuration of Apache Sling Main Servlet . In the Configuration Manager (<domain>:<port>/system/console/configMgr) look for Apache Sling Main Servlet and configure Default Parameter Encoding property.

For 6.0 (credits - Francois Cournoyer) : The configuration has been moved to Apache Sling Request Parameter Handling

Configure Temporary File Location to point to an absolute path in case of errors while saving the configuration




回答2:


For forms within CQ always have a hidden field with the charset set to UTF-8 or the charset of your HTML:

<input type="hidden" name="_charset_" value="UTF-8"/>

This will ensure proper encoding when the servlet retrieves the post.




回答3:


Need to add the Default charset change as part of response header. Here is the detailed process

http://localhost:4502/system/console/configMgr
 -->Apache Sling Main Servlet 
    -->     Additional response headers add the below entry
                 Content-Type=text/html;charset=utf-8


来源:https://stackoverflow.com/questions/28842990/aem-cq5-request-parameter-not-utf-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!