Do not use PrintWriter. Instead return mutationService.getPatientMutationData("3","") and add produces = "text/plain" to RequestMapping annotation