SSM整合事出现 Cannot find class [org.springframework.http.converter.json.MappingJacksonHttpMessageConvert

1:出错地方在Spring配置文件中,有个bean,id为mappingJacksonHttpMessageConverter,class为 

“org.springframework.http.converter.json.MappingJacksonHttpMessageConverter”

避免 IE 执行 Ajax时,返回json 出现下载文件

<bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean
                    class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"
                    p:supportedMediaTypes="*/*" />
        </mvc:message-converters>
    </mvc:annotation-driven>

出现这个问题的原因:

这个要注意spring版本,3.x和4.x配置不同(配置class的类不同)

spring3.x是org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

spring4.x是org.springframework.http.converter.json.MappingJackson2HttpMessageConverter

更改后:
 <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean
                    class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"
                    p:supportedMediaTypes="*/*" />
        </mvc:message-converters>
    </mvc:annotation-driven>

启动项目,不在报错、


展开阅读全文

没有更多推荐了,返回首页