I am Using soring MVC 3.2.1.I am using a controller which should return a json, I have included jackson jars too.But json is not returned.It give error The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().
@RequestMapping(value = "/search.json", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
protected @ResponseBody
LoginDto searchDeals(@ModelAttribute Deal deal) {
/*
* DealDao dealdao = new DealDao(); List<Deal> deals =
* dealdao.search(deal);
*/
return new LoginDto("sdadas", "asdasdas");
}
config
<!--
<bean name="/UploadEmployeeServlet.do"
class="com.etnow.UploadEmployeeServlet" />
-->
<context:component-scan base-package="com.etnow.*" />
<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="false" />
<property name="ignoreAcceptHeader" value="false" />
<property name="mediaTypes">
<value>
json=application/json
</value><!--
-->
</property>
</bean>
<mvc:view-controller path="/one.do" view-name="SignUp" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
Please help It works fine in 3.0 without setting contentNogotiation Manager but not in the latest version of spring MVC