1

I wonder if can replace the filter CharacterEncodingFilter by the HttpEncodingProperties.

I saw at documentation below ones:

# HTTP encoding (HttpEncodingProperties)
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true

Will it have the same effect that applying the filter manually? Another question, if I want to inform Spring Boot to keep the filter (properties) as async. Via filter I can inform it, setAsyncSupported(true).

Tks,

1
  • 1
    To answer the first part of your question - yes it is the same. If you look for usages of HttpEncodingProperties, you will find HttpEncodingAutoConfiguration class where the filter is created by Spring Boot based on those properties. Commented Nov 20, 2015 at 14:57

1 Answer 1

1

Spring Boot has many auto configurations per default, and http encoding is just one more using this concept.

Looking into the source code of HttpEncodingAutoConfiguration class, the filter CharacterEncodingFilter is created to encode all requests made to server. If you don't specify any property in application.properties the filter will be created using UTF-8, however if you decide creating this filter manually Spring Boot will use yours.

See source code: https://github.com/spring-projects/spring-boot/blob/2.6.x/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.