Skip to content

Commit

Permalink
REST默认返回JSON格式
Browse files Browse the repository at this point in the history
由于request中accept header中默认加入xml参数,导致contentNegotiationManager默认返回XML(即使设置defaultContentType=json)
还有加入ignoreAcceptHeader=true
  • Loading branch information
jtraviss committed Aug 20, 2014
1 parent 1cbf7f8 commit d84df3b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/showcase/src/main/webapp/WEB-INF/spring-mvc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

<!-- REST中根据URL后缀自动判定Content-Type及相应的View -->
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="ignoreAcceptHeader" value="true" />
<property name="defaultContentType" value="application/json" />
<property name="mediaTypes" >
<value>
json=application/json
Expand Down

0 comments on commit d84df3b

Please sign in to comment.