Could not find acceptable representation

報了一個這個異常:html

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

經過這篇文章找到了「favorPathExtension」關鍵字, Spring Boot完美解決(406)Could not find acceptable representation緣由及解決方法 進而找到了這篇文章中的方法,解決了問題 SpringMVC restful風格web

<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
	
	<bean id="contentNegotiationManager"
		  class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
		<property name="favorPathExtension" value="false" />
		<property name="favorParameter" value="true" />
		<property name="parameterName" value="mediaType" />
		<property name="ignoreAcceptHeader" value="true"/>
		<property name="useJaf" value="false"/>
		<property name="defaultContentType" value="application/json" />

		<!--<property name="mediaTypes">
			<map>
				<entry key="json" value="application/json" />
				<entry key="xml" value="application/xml" />
			</map>
		</property>-->
	</bean>
相關文章
相關標籤/搜索