I've added jackson's jars to my project's lib directory jackson-core-asl
and jackson-mapper-asl
. I also have wirtten in my dispatcher-servlet.xml the following:
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"></bean>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jacksonMessageConverter"/>
</list>
</property>
</bean>
My controller is:
@Controller
public class SaleController {
@RequestMapping(value = "/sales/info", produces = "application/json", headers = "Accept=*/*")
public @ResponseBody Product getProductJson(@RequestParam String id) throws SQLException
{
ProductDAO mapping = new ProductDAOImpl();
Product product = mapping.getProductById(Integer.parseInt(id));
return product;
}
}
But when I'm trying to get this response in the browser I still recieve 406 HTTP status message
instead of JSON-response.
NOTE: Before You mark my post as duplicate, I check this, this and this but it doesn't work.