Overview

Although ModelMap is not officially supported as an argument type for a WebFlux controller method, it still possible for a user to accidentally attempt to use ModelMap instead of Model or Map.

If ModelMap is used, the user currently encounters an exception similar to the following.

java.lang.IllegalStateException: argument type mismatch
Controller [org.springframework.web.reactive.config.WebFluxViewResolutionIntegrationTests$SampleController]
Method [java.lang.String org.springframework.web.reactive.config.WebFluxViewResolutionIntegrationTests$SampleController.index(org.springframework.ui.ModelMap)] with argument values:
 [0] [type=org.springframework.validation.support.BindingAwareConcurrentModel] [value={}]

The above is a bit cryptic since the error occurs while attempting to invoke the controller method with an instance of BindingAwareConcurrentModel which is not compatible with ModelMap.

Thus, we should improve diagnostics for the user in such scenarios by rejecting the use of ModelMap upfront in the ModelMethodArgumentResolver in WebFlux.

Related Issues

  • 33107