File extension takes precedence over accept headers when determinating which media type is supported.
Your .htm
will force it to be text/html
and not application/json
. To disable this you will have to configure the ContentNegotiationManager
yourself and disable favoring file extensions.
If you use xml you can use the ContentNegotiationManagerFactoryBean
to configure it and pass it as a reference to the <mvc:annotation-driven />
tag.
<bean id="contentNegotiationManager" class=" org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
</bean>
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
When using Java Config you can use the ContentNegotiationConfigurer
to do this.