The resource identified by this request is only capable of generating responses

今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常:

 

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().

这个错误是因为applicationContext缺少配置json转化bean:

 

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="messageConverters">  
            <list>  
                <ref bean="mappingJacksonHttpMessageConverter" />  
            </list>  
        </property>  
    </bean>  
    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">  
        <property name="supportedMediaTypes">  
            <list>  
                <value>application/json;charset=UTF-8</value>  
            </list>  
        </property>  
    </bean>  

 

你可能感兴趣的:(json,springMVC)