Align DispatcherServlet defaults for Java and XML
Closed this issue · 6 comments
In order to improve GraalVM compatibility (by requiring less reflection configuration) and for the sake of consistency, we should probably register these 4 missing beans in WebMvcConfigurationSupport
:
org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
org.springframework.web.servlet.theme.FixedThemeResolver
org.springframework.web.servlet.support.SessionFlashMapManager
org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator
We should also make sure the same is done on XML side and should then make DispatcherServlet.properties
parsing lazy as most use case will not use it.
Finally, we should check that no Spring Boot configuration update is needed.
I have a branch that includes these additional beans in both Java and XML configuration. I can provide a pull request if you like?
I was still pondering on the lazy loading. This kind of mechanism is used on other places as well, would it make sense to extract to loading of default strategies to a standalone class, for reuse in other places as well?
After a deeper look I think there is a 4th bean to add: org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator
.
Pull request added.
I considered adding a test to check if all the defaults have been added (1 for XML and 1 for Java), not sure if that would make sense or be helpful?
I think this is ok as provided in your PR, thanks.
Superseded by #25260.