`
id.alex
  • 浏览: 21989 次
社区版块
存档分类
最新评论

spring mvc 3.2.4 使用@ResponseBody 返回 406

    博客分类:
  • Java
阅读更多
	<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
	<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
		<property name="favorPathExtension" value="true" />
		<property name="favorParameter" value="false" />
		<property name="ignoreAcceptHeader" value="true" />
		<property name="mediaTypes">
			<props>
				<prop key="json">application/json</prop>
			</props>
		</property>
	</bean>


应该使用上面那段配置,原来的配置是:
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
		<property name="order" value="1" />
		<property name="contentNegotiationManager">
			<bean class="org.springframework.web.accept.ContentNegotiationManager">
				<constructor-arg>
					<bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
						<constructor-arg>
							<map>
								<entry key="json" value="text/html" />
							</map>
						</constructor-arg>
					</bean>
				</constructor-arg>
			</bean>
		</property>
		<property name="defaultViews">
			<list>
				<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
					<property name="extractValueFromSingleKeyModel" value="true" />
				</bean>
			</list>
		</property>
	</bean>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics