Could not find acceptable representation


報了一個這個異常:

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

通過這篇文章找到了“favorPathExtension”關鍵字,
Spring Boot完美解決(406)Could not find acceptable representation原因及解決方法
進而找到了這篇文章中的方法,解決了問題
SpringMVC restful風格

	<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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM