/**
* 将对象转换成json字符串格式
* @param value 需要转换的对象(注意,需要在要转换的对象中定义JsonFilter注解)
* @param properties 需要转换的属性
*/
public String writeObjectToJson(Object value, String[] properties) throws JsonGenerationException,
JsonMappingException, IOException {
return objectMapper.writer(
new SimpleFilterProvider().addFilter(AnnotationUtils.getValue(
AnnotationUtils.findAnnotation(value.getClass(), JsonFilter.class)).toString(),
SimpleBeanPropertyFilter.filterOutAllExcept(properties))).writeValueAsString(value); }调试了半天,想不明白AnnotationUtils.findAnnotation(value.getClass(), JsonFilter.class)报空指针异常
* 将对象转换成json字符串格式
* @param value 需要转换的对象(注意,需要在要转换的对象中定义JsonFilter注解)
* @param properties 需要转换的属性
*/
public String writeObjectToJson(Object value, String[] properties) throws JsonGenerationException,
JsonMappingException, IOException {
return objectMapper.writer(
new SimpleFilterProvider().addFilter(AnnotationUtils.getValue(
AnnotationUtils.findAnnotation(value.getClass(), JsonFilter.class)).toString(),
SimpleBeanPropertyFilter.filterOutAllExcept(properties))).writeValueAsString(value); }调试了半天,想不明白AnnotationUtils.findAnnotation(value.getClass(), JsonFilter.class)报空指针异常
解决方案 »
- 关于SpringMVC的问题
- 登录后用户信息如何安全
- 为什么用myeclipse创建在src下的servlet始终不能在工程的classes下创建.class文件??
- 求一个很常看到的效果
- 求助!!!!!!!!!!1
- 关于配置数据库连接池的问题
- 手机短信聊天室开发,有经验的请帮忙指点一下,有兴趣的欢迎加入,谢谢!
- 请教:怎么将.xml中的文件内容读到String变量里?
- JSP文件中.java编译后的.class文件应该放在什么地方?
- Tomcat上面只能访问html页面访问不了jsp页该怎么办??大神们
- 配置spring时的问题
- groovyUtils.setPropertyValue的用法
@JsonFilter("myFilter")
public class Notification implements java.io.Serializable, Cloneable { // Fields private Long id;
private String tableName;
private String cacheOperType;
private Long dataId;
private String variable;
------------------------------
your getter and setter
}