I am getting HTTP error code 406 with following error description:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
My Goal is to get my POJO class in json response. Kindly find my following configurations:
@RequestMapping(value="/testjson",produces="application/json")
public @ResponseBody Employee testjson () {
System.err.println("testing json");
Employee testEmp = new Employee("1", "Ankit", "Agarwal");
return testEmp;
}
spring-servlet.xml
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
<entry key="rss" value="application/rss+xml" />
</map>
</property>
</bean>