5 Replies Latest reply on May 19, 2017 2:05 PM by Kranthi Desaraju

    WildFly 10 - How to change default encoding?

    Niklas Arft Newbie

      Hi,

      I have a question. How can I configure WildFly / Undertow to set UTF-8 as default response encoding?
      I don't want to add ";charset=UTF-8" to every JAX-RS API therefore I am searching for a generic solution.

      I ran these commands, but they don't have the right effect.

      $WILDFLY_HOME/bin/./jboss-cli.sh --connect --command="/subsystem=undertow/servlet-container=default:write-attribute(name=use-listener-encoding,value=true)" > config.log 2>&1 &
      $WILDFLY_HOME/bin/./jboss-cli.sh --connect --command="/subsystem=undertow/servlet-container=default:write-attribute(name=default-encoding,value=UTF-8)" > config.log 2>&1 &
      

       

      Does anyone know, how I can fix this?

      Thank you in advance.
      Niklas

        • 1. Re: WildFly 10 - How to change default encoding?
          Tomaz Cerar Master

          jax-rs resources are not servlet resources, that is why config change you did does not apply.

           

          what is the version of wildfly you are using?

          • 2. Re: WildFly 10 - How to change default encoding?
            Niklas Arft Newbie

            Hi Tomasz,

             

            I am using the following version / Wildfly configuration.

             

            Product name:

            WildFly Full

            Product version:

            10.1.0.Final

            Profile:

            COMMUNITY

            HAL version:

            2.8.27.Final

            Core version:

            2.8.27.Final

            Standalone Server    Configurations:standalone.xml

             

            Thank you in advance.

             

            Niklas

            • 3. Re: WildFly 10 - How to change default encoding?
              jackie tsai Newbie

              You can add a filter for setting charactor encoding  as "utf-8", it makes sense in my case.

              Sure,If you still want to change setting for that,you can add config to standalone.xml as follows:

               

              <servlet-container name="default"  default-encoding="UTF-8">

               

              <system-properties>

              <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/> <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>

              </system-properties>

               

               

              The second section is only used for get request.

              • 4. Re: WildFly 10 - How to change default encoding?
                Tomaz Cerar Master

                jackie tsai wrote:

                 

                <system-properties>

                <property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/> <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>

                </system-properties>

                 

                 

                The second section is only used for get request.

                Properties named org.apache.catalina.* are no longer used in WildFly since it using undertow web server from version 8 onwards.

                 

                what are you guys looking for is setting on *-listener named uri-encoding

                <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true" url-charset="UTF-8"/>

                 

                 

                and similar for all other listeners you might be using.

                • 5. Re: WildFly 10 - How to change default encoding?
                  Kranthi Desaraju Newbie

                  Hi Tomaz,

                   

                        Facing the similar issue. I tried to update standalone.xml using the following CLI command.   But still now working.

                   

                        /subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=url-charset,value="utf-8")