SpringMVC Access Error No converter found for return value of type

When using SSM integrated, spring mvc add @ResponseBody when, under normal circumstances, would return the json. But if and when the configuration is not good, if you want to return to Map of json objects will be reported: No converter found for return value of type: class java.util.HashMap error.

As shown below:

String or Integer matter what type of results returned can return to normal, but if the object is returned, it would appear this error. Description in spring mvc json when converted into the wrong one.

Solution one:

Check pom.xml whether to add a jar jackson relevant.

We know that spring mvc default thing jackson used to convert the json. If not, you can add on.

Option II:

If you do not want to add in pom.xml, you can add the following configuration spring-mvc.xml in:

<! - start Springmvc annotation-driven ->

<mvc:annotation-driven/>

<! - json method returns a package need to import fastjson.jar ->

<mvc:annotation-driven>

<mvc:message-converters register-defaults="false">

<! - to avoid the implementation of AJAX IE, returns JSON appear download file ->

<bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">

<property name="supportedMediaTypes">

</property>

</bean>

</mvc:message-converters>

</mvc:annotation-driven>

 

Guess you like

Origin www.cnblogs.com/kaigejava/p/12032186.html