List of usage examples for org.springframework.http.converter AbstractHttpMessageConverter canWrite
@Override public boolean canWrite(Class<?> clazz, @Nullable MediaType mediaType)
From source file:com.wbss.mycoffee.ui.services.ApiController.java
/** * Write json data to response stream/*w w w .j av a2 s . c o 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)); } }