设置响应格式
2019獨角獸企業重金招聘Python工程師標準>>>
java代碼:
public?void?getUserNormal(HttpServletResponse?resp)?throws?IOException?{User?user?=?new?User();user.setId(1L);user.setName("李明");user.setPasswd("111111");Object?json?=?JSONObject.toJSON(user);//發送jsonresp.setContentType("application/json;charset=UTF-8");//發送xmlresp.setContentType("application/json;charset=UTF-8");//發送textresp.setContentType("application/json;charset=UTF-8");resp.getWriter().write(json.toString());}轉載于:https://my.oschina.net/sniperLi/blog/659438
總結
- 上一篇: android 启动过程
- 下一篇: Kafka使用入门教程