所以我写一个Spring(2.5(+泽西岛(1.1.4.1),并尝试使用ContextResolver创建JSONConfiguration这里是代码:新泽西春季实施ContextResolver <JAXBContext>
package com.rhigdon.jersey.config;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.api.json.JSONJAXBContext;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;
@Provider
public final class JAXBContextResolver implements ContextResolver<JAXBContext> {
private JAXBContext context;
public JAXBContextResolver() throws Exception {
this.context = new JSONJAXBContext(JSONConfiguration.mappedJettison().build(), "com.rhigdon.core.model.");
}
public JAXBContext getContext(Class<?> aClass) {
return context;
}
}
不幸的是我的应用程序仍返回默认映射:
{ “ID”: “1”, “问题”: “什么是/是你的第一个宠物的名字 ”}
当我调试应用程序时,它实际上从来没有碰到这个代码。这是由于使用SpringServlet吗?这里是我的球衣配置在web.xml中我:
<servlet>
<servlet-name>Jersey Spring Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Spring Web Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
任何有JSONConfiguration工作类似的设置?
这是一个很明显的解决方案,但我想万一有人来回答其他人有脑子一片空白像我一样。 :) – rhigdon 2009-12-21 23:29:29