SpringMVC 3.2 org.springframework.web.servlet.view.ContentNegotiatingViewResolver 配置如下mediaType报错 <property name="mediaTypes"> <map> <entry key="pdf" value="application/pdf"/> <entry key="html" value="text/html"/> <entry key="json" value="application/json"/> </map> </property> 换成
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="contentNegotiationManager"> <bean class="org.springframework.web.accept.ContentNegotiationManager"> <constructor-arg> <list> <!-- These are evaluated in order --> <!-- Is there a media type based on suffix? --> <bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy"> <constructor-arg> <map> <entry key="html" value="text/html" /> <entry key="json" value="application/json" /> <entry key="pdf" value="application/pdf" /> </map> </constructor-arg> </bean> <!-- Else use request header --> <bean class="org.springframework.web.accept.HeaderContentNegotiationStrategy"> </bean> </list> </constructor-arg> </bean> </property> </bean>
springMVC3.2 多视图解析器 java.lang.String cannot be cast to org.springframework.http.MediaType
最新推荐文章于 2024-02-22 17:06:52 发布