Background
A clean spring+spring mvc+mybatis frame is required, and the framework writes the error to the return JSON link.
Problem
Can't json, quote 406
Solve
Need to configure the JSON toolkit, here with Jackson
Maven Jackson
<!-- https://mvnrepository.com/artifact/ com.fasterxml.jackson.core/jackson-core --> < Dependency> <groupid> com.fasterxml.jackson.core</groupid> <artifactId>jackson-core</artifactId> <version>2.6.0</version> </ dependency> <!-- https://mvnrepository.com/artifact/ com.fasterxml.jackson.core/jackson-annotations --> < Dependency> <groupid> com.fasterxml.jackson.core</groupid> <artifactid>jackson-annotations</ artifactid> <version>2.6.0< /version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactid>jackson-databind</ artifactid> <version>2.6.0< /version> </dependency>
Engineering Environment SPRINGMVC 4.x, incompatible with Jackson2.9 latest version. Here Special Application 2.6 version
Spring MVC Configuration
<!--Begin: Use the jackson 2.x configuration to import the jar package: Jackson-core-xxx.jar, Jackson-annotations-xxx.jar, jackson-databind-xxx.jar--> <!-- Turn on support for @controller annotations with processor mapping defaultannotationhandlermapping--> <bean class= " Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping " /> <!--to enable @requestmapping annotations via the processor adapter Annotationmethodhandleradapter--> <bean class= "Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" > <property name= "Messageconverters" > <list> <!-- Set return string encoding --> <bean class= "Org.springframework.http.converter.StringHttpMessageConverter" > <property name = "Supportedmediatypes" > <list > <value>text/html;charset=utf-8</ value> <value>application/json;charset= utf-8</value> </list> </property> </bean> <!-- json Converters --> <bean class= " Org.springframework.http.converter.json.MappingJackson2HttpMessageConverter "> <property Name= "Supportedmediatypes" > <list> &nbSp; <value >text/html;charset=UTF-8</value> < value>application/json;charset=utf-8</value> </list> </property> </bean> </list> </property> </bean> <!--End: MakeWith jackson 2.x configuration, the jar package that needs to be imported: Jackson-core-xxx.jar, Jackson-annotations-xxx.jar, jackson-databind-xxx.jar-->
OK, reboot does not error (in general is the Jar Treasure conflict), you can normally receive the JSON returned by @responsebody.
The above configuration, bring luck, good luck!
By. Foam Gold
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/E4/wKiom1mIJqawDcJKAAAyzXs0nSM846.jpg "title=" Qq20170807163837.jpg "alt=" Wkiom1mijqawdcjkaaayzxs0nsm846.jpg "/>
I have to clean the frame, the new module only needs a controller to be able, crud a sentence to complete. Front desk focus on the form on the line.
This article is from the "foam gold it experience and skills" blog, please be sure to keep this source http://zl0828.blog.51cto.com/2242565/1954239
SPRINGMVC return JSON failed, please check if Jackson is configured