标签:http io ar java sp 数据 on art bs
@RequestMapping("/findByItem")
public void findByItem(int pageNO,String userName,Date startDate,Date endDate,HttpServletResponse response)throws Exception{
CutPageBean cutBean = service.findByItem(pageNO, userName, startDate, endDate);
//创建jackson对象
ObjectMapper om = new ObjectMapper();
//创建输出属性过滤器
SimpleFilterProvider filterProvider = new SimpleFilterProvider().
setFailOnUnknownId(false);
//定义指定实体bean需要转化的属性列表
filterProvider.addFilter("ub", SimpleBeanPropertyFilter. //ub为定义的要过滤的javabean对象 详细见下
filterOutAllExcept("id","userName","birthday"));
om.setFilters(filterProvider);
//将指定对象转换为json格式发送到客户端
om.writeValue(response.getWriter(), cutBean);
}
数据javabean
@Entity
@Table(name="t_user")
@JsonFilter("ub") //指定json的过滤器ID 调用时就会过滤此ID的类
public class UserBean {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
private String userName;
private Date birthday;
标签:http io ar java sp 数据 on art bs
原文地址:http://www.cnblogs.com/sanhuan/p/4057938.html