Last active
April 13, 2019 11:29
-
-
Save brunoleles/a6e3edc46d5c9ef23fa4cae3fba42dc9 to your computer and use it in GitHub Desktop.
Apache + Tomcat ( UTF-8 encoding AND @RequestParam( ) )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
... | |
AddDefaultCharset utf-8 | |
JkOptions +ForwardURIProxy | |
... | |
</VirtualHost> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8' standalone="no"?> | |
<Server port="9205" shutdown="SHUTDOWN"> | |
... | |
<Service name="Catalina"> | |
... | |
<Connector protocol="HTTP/1.1" ... URIEncoding="UTF-8" /> <!-- for direct tomcat access --> | |
<Connector protocol="AJP/1.3" ... URIEncoding="UTF-8" /> <!-- for access with apache mod_jk --> | |
... | |
</Service> | |
</Server> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<web-app | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee | |
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" | |
version="3.0"> | |
... | |
<filter> | |
<filter-name>setCharacterEncodingFilter</filter-name> | |
<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class> | |
<init-param> | |
<param-name>encoding</param-name> | |
<param-value>UTF-8</param-value> | |
</init-param> | |
<async-supported>true</async-supported> | |
</filter> | |
... | |
<filter-mapping> | |
<filter-name>setCharacterEncodingFilter</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
... | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configuration I used to "fix" the UTF-8 encoding in a Apache + Tomcat + Spring stack
001-default.conf
server.xml, web.xml
References
https://confluence.atlassian.com/doc/configuring-url-encoding-on-tomcat-application-server-174898.html
https://cwiki.apache.org/confluence/display/WW/How+to+support+UTF-8+URIEncoding+with+Tomcat
https://struts.apache.org/docs/how-to-support-utf-8-uriencoding-with-tomcat.html
https://svn.apache.org/repos/asf/tomcat/trunk/webapps/host-manager/WEB-INF/web.xml
http://stackoverflow.com/questions/913869/how-to-change-the-default-encoding-to-utf-8-for-apache
http://stackoverflow.com/questions/35395388/where-how-to-add-adddefaultcharset-utf-8-in-httpd-conf