Spring 4 MVC based project with xml based configuration, want to use Jackson binding to return Json for some of the controller mappings (and it's going to Google App Engine). Did a lot of investigating, many different solution but they doing, each one, a bit different approach then the one we have. No yet working solution.
web.xml file:
<?xml version="1.0" encoding="utf-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-config/application-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Spring application-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd ">
<context:component-scan base-package="com.wixpress.automation"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
My example controller is pretty slim:
@Controller
@RequestMapping("/api/")
public class Controller {
@RequestMapping(value = "/name", method = RequestMethod.GET)
@ResponseBody
public Name nameexample(WebRequest request, Model model) {
final Name name = new Name("name", "class", "package");
return name;
}
}
The class Name is a simple POJO with getters/setters, implements Serializable.
pom.xml got all the Jackson dependencies: jackson-databind, jackson-core, jackson-annotations, version 2.6.0. Spring used: 4.2.0.RELEASE
The error I receive when trying to GET the url: org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation