json java.lang.ClassNotFoundException: Spring 3 项目上的 org.codehaus.jackson.map.ObjectMapper
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11123596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.ClassNotFoundException: org.codehaus.Hymanson.map.ObjectMapper on Spring 3 project
提问by gc5
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
我正在尝试建立一个没有 Maven 的 Spring 项目。我的项目必须通过 Spring MVC 框架提供 jsp 页面和 json 流。Jsp 页面的部分运行良好,但是当我尝试设置 json 流(为了制作 ajax GET)时,我得到
java.lang.ClassNotFoundException: org.codehaus.Hymanson.map.ObjectMapper
My servletname-servlet.xml is the following:
我的 servletname-servlet.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.MappingHymansonJsonView" />
</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;
}
}
Thanks
谢谢

