List of usage examples for org.springframework.http.converter AbstractHttpMessageConverter write
@Override public final void write(final T t, @Nullable MediaType contentType, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException
From source file:com.wbss.mycoffee.ui.services.ApiController.java
/** * Write json data to response stream//from w w w . j ava 2 s .co m * @param json * @param response * @throws Exception */ private void wirteJsonToResponse(String json, HttpServletResponse response) throws Exception { AbstractHttpMessageConverter<String> stringHttpMessageConverter = new StringHttpMessageConverter( Charset.forName("UTF-8")); MediaType jsonMimeType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("UTF-8")); if (stringHttpMessageConverter.canWrite(String.class, jsonMimeType)) { stringHttpMessageConverter.write(json, jsonMimeType, new ServletServerHttpResponse(response)); } }