Spring MVC custom argument resolvers order
See original GitHub issueWhen I want to custom one argument Resolver in : WebMvcConfigurerAdapter#addArgumentResolvers,and try to override parameter type of ServletRequest ; but I found it that caught low priority after ServletRequestMethodArgumentResolver (same parameter type of ServletRequest) ; review source RequestMappingHandlerAdapter#getDefaultArgumentResolvers discover below :
`// Type-based argument resolution
resolvers.add(new ServletRequestMethodArgumentResolver());
resolvers.add(new ServletResponseMethodArgumentResolver());
resolvers.add(new HttpEntityMethodProcessor(getMessageConverters()));
resolvers.add(new RedirectAttributesMethodArgumentResolver());
resolvers.add(new ModelMethodProcessor());
resolvers.add(new MapMethodProcessor());
resolvers.add(new ErrorsMethodArgumentResolver());
resolvers.add(new SessionStatusMethodArgumentResolver());
resolvers.add(new UriComponentsBuilderMethodArgumentResolver());
// Custom arguments
if (getCustomArgumentResolvers() != null) {
resolvers.addAll(getCustomArgumentResolvers());
}
`
I think that custom arguments resolver should be before the default argument ,so that can get highly priority to handle my logic; Thanks .
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Improve Your Spring MVC Argument Resolvers Using Filters
Improve Your Spring MVC Argument Resolvers Using Filters ... Method argument resolvers are a great tool to keep your Spring application clean.
Read more >spring - What is happening with default argument resolver ...
@Antoniossss I think yes, every configuration been has LOWEST_PRECEDENCE by default, but you can use @Order to ensure priority for your custom ......
Read more >How to implement custom parameter mapping in Spring MVC
In this tutorial, we will discuss HandlerMethodArgumentResolver which is being used to resolve the arguments of the public MVC methods (handler ...
Read more >Using Custom Data Binders in Spring MVC - Baeldung
Custom Argument Resolver. As we can see, HandlerMethodArgumentResolver's resolveArgument() method returns an Object. In other words, we could ...
Read more >Using custom arguments in Spring MVC controllers - Sadique Ali
Most of the Spring controllers in the real world accept a lot of different types of parameters - Path variables, URL parameters, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the end, I found an workaround. But I don’t think it’s the best
Okay but just to be clear, the change I suggested in
ServletRequestMethodArgumentResolverwould have made your custom resolver work with the current order, because the built-in resolver would pass on any concrete request type it does not recognize.