Spring, Java - @ResponseBody(JSON) request returning Internal Server Error 500

Problem:

Requests to return an JSON object returns Internal Server Error 500

Solution:


Controller:


@RequestMapping(method = RequestMethod.GET, value = "/get")

public @ResponseBody Question getQuestionsAjax() {
                (...)
return (...);
}

mvc-dispatcher-servlet.java:

<!-- Set the Spring context to allow for dispatching request to Controllers -->
<mvc:annotation-driven/>
<!--  Allow JSON objects to be returned -->
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>

Pom.xml

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.0</version>
</dependency>

@RequestMapping(method = RequestMethod.GET, value = "/get")
  public @ResponseBody Question getQuestionsAjax() {
                (...)
  return (...);
 }

Comments

Popular posts from this blog

Oracle - duplicate fields in RECORD,TABLE or argument list are not permitted

Oracle - ORA-29282: invalid file ID, ORA-06512: at "SYS.UTL_FILE"