在春季3项目组织codehaus

在春季3项目组织codehaus

本文介绍了抛出java.lang.ClassNotFoundException:在春季3项目组织codehaus.jackson.map.ObjectMapper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立没有一个Maven的Spring项目。我的项目必须服务于JSP页面和JSON数据流通过Spring MVC框架。 jsp页面部分工作得很好,但是当我尝试设置JSON流(为了使AJAX取)我收到

I am trying to set up a Spring project without Maven. My project has to serve jsp pages and json streams via Spring MVC framework. Jsp pages' section works well, but when I try to set up json streaming (in order to make ajax GETs) I get

java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper

我的servletname-servlet.xml文件如下:

My servletname-servlet.xml is the following:

<?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>

我的控制器是以下

My controller is the following

package org.package.servletname;

import java.util.LinkedList;
import java.util.List;

import org.package.servletname.orm.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ajax")
public class JSONGetController
{
@RequestMapping(value = "/getproducts", method = RequestMethod.GET)
public @ResponseBody
List<Product> JSONGetProducts()
{
    List<Product> productList = null;
    Product p = new Product();
    p.setName("ProductName");
    productList = new LinkedList<Product>();
    productList.add(p);
    return productList;
}
}

感谢

推荐答案

杰克逊是失踪类路径

这篇关于抛出java.lang.ClassNotFoundException:在春季3项目组织codehaus.jackson.map.ObjectMapper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 03:45