As you know, we can create singleton bean as follow:
@Bean(name = "localeResolver")
public LocaleResolver cookieLocaleResolver() {
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
localeResolver.setDefaultLocale(new Locale("ko"));
return localeResolver;
}
But for ContentNegotiationResolver, we've recommended to use the following code to instantiate a default ContentNegotiationResolver since spring 3.2
@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
ContentNegotiatingViewResolver contentNegotiatingViewResolver = new ContentNegotiatingViewResolver();
contentNegotiatingViewResolver.setOrder(0);
contentNegotiatingViewResolver.setContentNegotiationManager(manager);
List<View> views = new ArrayList<View>();
views.add(new CommonMappingJackson2JsonView());
contentNegotiatingViewResolver.setDefaultViews(views);
return contentNegotiatingViewResolver;
}
as you can see, the above method has the parameter, ContentNegotiationManager.
Here is my question: How client of the above @bean
method can create a argument? and which value of properties does the argument ContentNegotiationManager
?
spring framework was instructed to create a ContentNegotiation bean but not ContentNegotiationManger.
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire