What does the following setting in application.properties
in a Spring application do?
server.error.include-binding-errors=on-param
I can't find it in the documentation.
The always
and never
values are pretty self-explanatory, but I don't understand on-param
.
To begin, what I did is to do a global search on
server.error.include-binding-errors
in the library, which lead me tospring-configuration-metadata.json
We see the related attribute is
errors
here, and the value class isIncludeAttribute
. By checking the documentation in IncludeAttribute#ON_PARAMWe know that the
errors
attribute will be added when there is a request parameter that is not "false".If you want something concrete, let's consider the following example:
Controller
DTO
Suppose we set
server.error.include-binding-errors=on-param
When we run with parameter errors=false
the result will not include
errors
When we run with parameter errors=true
the result will include
errors
asReferences:
Implementation for web reactive
DefaultErrorWebExceptionHandler#isIncludeBindingErrors
AbstractErrorWebExceptionHandler#isBindingErrorsEnabled
Implementation for web servlet
BaseErrorController#isIncludeBindingErrors
AbstractErrorController#isBindingErrorsEnabled