PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/com/tmm/nosql/mongodb/views/AjaxView.java

https://github.com/robhinds/SpringMongoIntegrationExample
Java | 20 lines | 14 code | 6 blank | 0 comment | 0 complexity | 7578e5e0825c524fa423cc724f201f06 MD5 | raw file
  1. package com.tmm.nosql.mongodb.views;
  2. import java.util.Map;
  3. import javax.servlet.http.HttpServletRequest;
  4. import javax.servlet.http.HttpServletResponse;
  5. import org.springframework.web.servlet.view.AbstractView;
  6. import com.google.gson.Gson;
  7. public class AjaxView extends AbstractView {
  8. @Override
  9. protected void renderMergedOutputModel(Map map, HttpServletRequest request, HttpServletResponse response) throws Exception {
  10. String jsonString = new Gson().toJson(map);
  11. response.setContentType( "text/plain; charset=UTF-8" );
  12. response.getOutputStream().write( jsonString.getBytes() );
  13. }
  14. }