reset password
Author Message
dhaval0704
Posts: 14
Posted 23:22 Feb 23, 2016 |

I got error like java.lang.ClassNotFoundException: org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.

I have already defined dependencies   in pom.xml.

<dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.0</version>
        </dependency>

I am facing problem to convert list to json as a resonse from controller.       

 

 

cysun
Posts: 2935
Posted 11:39 Feb 24, 2016 |

According to this, that class is deprecated in Spring 4.

There are plenty of ways to convert Java objects to JSON (you can even create JSON by string concatenation). You can check out the RESTful Web Service Examples to see how to do it with a Spring MappingJackson2JsonView. You can also use Jackson's ObjectMapper directly - see ForumControllerS.java in CSNS2 for example.

Last edited by cysun at 11:41 Feb 24, 2016.