Writer와 ServletOutputStream의 차이

res.setContentType(“application/json; charset=utf-8”); // 以下方法だと JournalのWrapperにキャッチされる Writer out = res.getWriter(); out.write(JSON.encode(responseMap)); out.flush(); // ServletOutputStream sos = res.getOutputStream(); // sos.write(JSON.encode(responseMap).getBytes(“utf-8”)); // sos.flush(); // sos.close(); Writer로하면 밑에서의 로그처럼 응답내용을 Wrapper할 수 있다.

2014-04-19 00:06:01,597 INFO [MobileFilter : 337] [ ] ( ) RESPONSE[1] – Status : 200 – Time Elapsed : 742ms – Content-Type : application/json;charset=utf-8 – Content-Length : 174 – Character-Encoding : utf-8 – Body : {“teams”:{“1313”:{“draw”:1,”id”:1313,”lose”:66,”rank”:10381,”level”:2,”initial”:”TMG”,”name”:”ケイゴーズ”,”address1″:”兵庫県”,”win”:41,”logoId”:1714}},”mode”:”login”}
Stream의 경우는 불가능하다.]]>

Related Posts