JSON格式输出Struts2

时间:2014-08-11 12:16:32   收藏:0   阅读:232
public void JSON(Object object,String charset){

  getHttpResponse().setCharacterEncoding(charset);

  getHttpResponse().setContentType("text/html;charset="+charset);

  try {

   JSONUtil.serialize(getHttpResponse().getWriter(), object);

   getHttpResponse().getWriter().flush();

   getHttpResponse().getWriter().close();

  } catch (Exception e) {

   e.printStackTrace();

  }

 }

JSON格式输出Struts2,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!