Spring MVC No converter found for return value of type solution

1. Add jackson to pom

 1  <properties>
 2     <jackson.version>2.8.5</jackson.version>
 3 </properties>
 4 
 5 <!-- jackson -->
 6     <dependency>
 7         <groupId>com.fasterxml.jackson.core</groupId>
 8         <artifactId>jackson-core</artifactId>
 9         <version>${jackson.version}</version>
10     </dependency>
11     <dependency>
12         <groupId>com.fasterxml.jackson.core</groupId>
13         <artifactId>jackson-databind</artifactId>
14         <version>${jackson.version}</version>
15     </dependency>
16     <dependency>
17         <groupId>com.fasterxml.jackson.core</groupId>
18         <artifactId>jackson-annotations</artifactId>
19         <version>${jackson.version}</version>
20     </dependency>

2. Configure in the spring configuration file

1 <mvc:annotation-driven >
2         <mvc:message-converters>
3             <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
4             <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
5         </mvc:message-converters>
6     </mvc:annotation-driven>

3. Add the @ResponseBody tag to the controller

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325596597&siteId=291194637