org.springframework.web.filter

Class CharacterEncodingFilter

    • Constructor Detail

      • CharacterEncodingFilter

        public CharacterEncodingFilter(java.lang.String encoding)
        Create a CharacterEncodingFilter for the given encoding.
        Parameters:
        encoding - the encoding to apply
        Since:
        4.2.3
        See Also:
        setEncoding(java.lang.String)
      • CharacterEncodingFilter

        public CharacterEncodingFilter(java.lang.String encoding,
                                       boolean forceEncoding)
        Create a CharacterEncodingFilter for the given encoding.
        Parameters:
        encoding - the encoding to apply
        forceEncoding - whether the specified encoding is supposed to override existing request and response encodings
        Since:
        4.2.3
        See Also:
        setEncoding(java.lang.String), setForceEncoding(boolean)
      • CharacterEncodingFilter

        public CharacterEncodingFilter(java.lang.String encoding,
                                       boolean forceRequestEncoding,
                                       boolean forceResponseEncoding)
        Create a CharacterEncodingFilter for the given encoding.
        Parameters:
        encoding - the encoding to apply
        forceRequestEncoding - whether the specified encoding is supposed to override existing request encodings
        forceResponseEncoding - whether the specified encoding is supposed to override existing response encodings
        Since:
        4.3
        See Also:
        setEncoding(java.lang.String), setForceRequestEncoding(boolean), setForceResponseEncoding(boolean)
    • Method Detail

      • getEncoding

        @Nullable
        public java.lang.String getEncoding()
        Return the configured encoding for requests and/or responses.
        Since:
        4.3
      • setForceRequestEncoding

        public void setForceRequestEncoding(boolean forceRequestEncoding)
        Set whether the configured encoding of this filter is supposed to override existing request encodings.

        Default is "false", i.e. do not modify the encoding if ServletRequest.getCharacterEncoding() returns a non-null value. Switch this to "true" to enforce the specified encoding in any case.

        Since:
        4.3
      • isForceRequestEncoding

        public boolean isForceRequestEncoding()
        Return whether the encoding should be forced on requests.
        Since:
        4.3
      • setForceResponseEncoding

        public void setForceResponseEncoding(boolean forceResponseEncoding)
        Set whether the configured encoding of this filter is supposed to override existing response encodings.

        Default is "false", i.e. do not modify the encoding. Switch this to "true" to enforce the specified encoding for responses in any case.

        Since:
        4.3
      • isForceResponseEncoding

        public boolean isForceResponseEncoding()
        Return whether the encoding should be forced on responses.
        Since:
        4.3