Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encoding servlets with UTF-8 on WildFly

I used to run my JavaEE applications on GlassFish server, and there was no problem with the encoding type (UTF-8) since I added the following property in JVM Settings of the server:

file.encoding = UTF-8

Now, I'm using WildFly server instead, and I've done the supposed configuration to set the encoding type into UTF-8 but characters are still appearing with wrong encoding not only on the web page but also while debugging the application with Eclipse, the response data loaded using (web servlet requests) are not UTF-8 encoded. Below is what I did on WildFly:

snapshot1

snapshot2

like image 751
Samir Avatar asked Jul 03 '15 11:07

Samir


1 Answers

Wildfly now uses Undertow, so check for that subsystem in you configuration file:

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
      <server name="default-server">
         <http-listener name="default" socket-binding="http" redirect-socket="https" url-charset="UTF-8" />
      </server>
      <servlet-container default-encoding="UTF-8" name="default">
         <jsp-config />
         <websockets />
      </servlet-container>
   </subsystem>

With url-charset and default-encoding set there is no need for filter.

like image 97
user158037 Avatar answered Sep 21 '22 00:09

user158037