Hi together,
I used to config ContentNegotiatingViewResolver in Spring3.1 with inject mediaTypes as
but in spring3.2 setMediaTypes is deprecated in ContentNegotiatingViewResolver and suggest to use setContentNegotiationManager.Code:<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="json" value="application/json"/> </map> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> </list> </property> </bean>
Furthermore, if I use mediaTypes in spring3.2 it will thorw a ClassCastException in its parent class MappingMediaTypeFileExtensionResolver
I don't know how to declare a contentNegotiationManager and inject into ContentNegotiatingViewResolver or how to use ContentNegotiationStrategy in Spring MVC3.2Code:java.lang.ClassCastException: java.lang.String cannot be cast to org.springframework.http.MediaType at org.springframework.web.accept.MappingMediaTypeFileExtensionResolver.<init>(MappingMediaTypeFileExtensionResolver.java:56) at org.springframework.web.accept.AbstractMappingContentNegotiationStrategy.<init>(AbstractMappingContentNegotiationStrategy.java:42) at org.springframework.web.accept.PathExtensionContentNegotiationStrategy.<init>(PathExtensionContentNegotiationStrategy.java:74) at org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy.<init>(ServletPathExtensionContentNegotiationStrategy.java:47) at org.springframework.web.accept.ContentNegotiationManagerFactoryBean.afterPropertiesSet(ContentNegotiationManagerFactoryBean.java:166) at org.springframework.web.servlet.view.ContentNegotiatingViewResolver.afterPropertiesSet(ContentNegotiatingViewResolver.java:270)
Any ideas?
Thanks!


Reply With Quote