Мой сервер не может получать корейских символов через запрос POST и не может записывать их на консоль.Чтение корейских символов из сервлета Tomcat
Вот мой код:
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException {
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
StringBuffer buffer = new StringBuffer();
String line = null;
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null)
buffer.append(line);
String requestMessage = buffer.toString();
//working
System.out.println("teniszütő");
//not working (???????)
System.out.println("\uc548\ub155\ud558\uc138\uc694\uc138\uacc4");
//not working (??)
System.out.println("여니");
//accents are working, Korean characters aren't
System.out.println(requestMessage);
//writing 3F (the code of the ? instead of the code of the character)
System.out.println(bytesToHexString(requestMessage.getBytes()));
out.println("Answer");
}
Я использую Eclipse, и если я проверить свойства проекта я могу видеть, что «Кодировка текста файла» является «Наследуется из контейнера (UTF-8)». Если я создаю обычное приложение HelloWorld (с теми же настройками), он печатает корейские символы.
Благодарим за помощь!