zoukankan      html  css  js  c++  java
  • @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)

    一:
      response.setContentType("text/html;charset=utf-8");
      ObjectMapper mapper=new ObjectMapper();
      JsonFactory factory=mapper.getJsonFactory();
      JsonGenerator jsonGenerator=factory.createJsonGenerator(response.getOutputStream());
      Map map=new HashMap();
      map.put("result", "1");
      jsonGenerator.writeObject(map);
    二:JsonObject json=new JsonObject();
            json=JsonObject.fromJsonObject(object);
          response.setContentType("text/html;charset=utf-8");
          response.getWriter().write(json);
     
    三:
    spring MVC 3.X 支持注解,在需要序列化为json输出的类上增加@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
    //@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
    public class ActTerminalResultParam extends BaseFacadeAmountDepositTradeParam
    implements Serializable{
     
    注意:在类上注入此标志时,返回此类时,会返回set属性里的值
  • 相关阅读:
    php 手动搭建环境
    C#开源大全项目
    基于Aforge的物体运动识别-入门
    第二阶段站立会议02
    第二阶段站立会议01
    第一次绩效评估
    意见评论
    团队项目评论
    意见汇总
    对“小小之植物人”的博客检查结果
  • 原文地址:https://www.cnblogs.com/front-end-develop/p/8250199.html
Copyright © 2011-2022 走看看