一:
  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属性里的值

相关文章:

  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-01-30
  • 2021-12-24
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2022-02-28
  • 2021-07-22
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2021-08-14
相关资源
相似解决方案