json 응답에서 스페인어 텍스트를 사용해야합니다. 모든 가능한 방법을 시도했지만 메시지는 여전히 UI에서 이상한 문자를 보여줍니다. 자바 측면에서 JSON 응답의 특수 문자 인코딩
N�mero de Seguro Social
,
//response.setContentType("application/json");
//response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=utf-8");
OutputStream out = null;
out = response.getOutputStream();
out.write(jsonResponse.toString().getBytes());
out.close();
머리 부분에 메타 태그를 추가, 내가 보여주고 싶은 메시지는,
Número de Seguro Social
입니다 그러나로 표시됩니다.
<meta http-equiv="content-type" content="text/html;charset=utf-8">
나는 또한 Ajax 호출
$.ajax({
async: false,
cache: false,
type: get,
contentType: "application/json; charset=utf-8",
url: //url,
data: //data,
dataType: //dataType,
success: //callbackfn,
error: //errorfn
});
아무것도에 콘텐츠 형식을 설정 한 작동 보인다. 의도 한대로 특수 문자가 작동하도록하기 위해 할 수있는 다른 방법이 있습니까?
감사 @Danack ... 트릭() getBytes로 캐릭터 세트를 않았다 통과 .. 'jsonResponse.toString(). getBytes (Charset.forName ("UTF-8")' – RKodakandla
@rrkwells 당신을 JSON을 Java로 직접 인코딩하고 싶지는 않습니다. – Danack