我正在为使用Gson API的Jersey实现一个JSON实体提供程序, 下面是我写的“
提供者的重要方法 @Override
public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try {
Object bean = getResponseBean(object);
gson.toJson(bean, bean.getClass(), writer);
} finally {
writer.close();
}
}
我现在面临的问题是“使用@InjectLink注释”的注入链接不再起作用,它们完全被忽略了!
@InjectLink("/Link/...")
@XmlElement(name = "documentURI")
String documentURI;