【问题标题】:about spring mvc error no class def found关于spring mvc error no class def found
【发布时间】:2012-12-12 21:20:51
【问题描述】:

我收到错误 NOClassDefFound for org/codehaus/jackson/map/objectmapper ,我的 spring xml 文件如下所示

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
     ">
<mvc:annotation-driven />
<context:component-scan base-package="org.package.servletname" />

<bean
    class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    <property name="mediaTypes">
        <map>
            <entry key="atom" value="application/atom+xml" />
            <entry key="html" value="text/html" />
            <entry key="json" value="application/json" />
        </map>
    </property>
    <property name="viewResolvers">
        <list>
            <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
            <bean
                class="org.springframework.web.servlet.view.InternalResourceViewResolver">
                <property name="prefix" value="/WEB-INF/jsp/" />
                <property name="suffix" value=".jsp" />
            </bean>
        </list>
    </property>
    <property name="defaultViews">
        <list>
            <bean
                class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
        </list>
    </property>
</bean>

<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/img/**" location="/img/" />
<mvc:resources mapping="/js/**" location="/js/" />

</beans>

我正在尝试用我的 spring 映射 json,所以请指教。

【问题讨论】:

    标签: java spring model-view-controller spring-mvc


    【解决方案1】:

    错误清楚地表明您的类路径中没有 Jackson JAR。您是否在类路径中添加了 Jackson JSON JAR 文件?

    【讨论】:

    • 我尝试使用 glass fish 在 netbeans 上运行我的项目,它在 spring 配置文件上没有任何配置就可以正常工作,但是当我尝试使用 tom cat 时,我遇到了同样的问题
    猜你喜欢
    • 2013-08-20
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    • 2015-12-06
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 2020-10-11
    相关资源
    最近更新 更多