Tell me please. I do not know what to do. I use IDEA. There is a Java EE project. Spinning on Tomcat. The problem is that Russian characters are not perceived at all - instead of them question marks. There is also such a problem with incoming requests from the client from the site - when sending data from the ajax
client in which there are Russian characters, all these Russian characters in the servlet become question marks (I wrote about this problem here ).
But this problem also affected the simple output of Russian characters to the console. All that I was advised, I tried it on the forums - it does not help. Exhibited and chcp
on 866
, chcp
in meta tags on the pages, changed the encoding of the IDEA itself and the project itself and the files themselves in the IDEA settings - it costs UTF-8 everywhere. I do not know what to do anymore. Even if you print the Russian string in the jsp
file, there will still be question marks.
UPD # 1 - Eclipse is the same. Created a project file - Russian characters in the form of question marks.
Example:
JSP:
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta charset="utf-8" /> <title>$Title$</title> </head> <body> <form action="Character" method="get"> <input type="text" name="text" id="text"> <button type="submit">OK</button> </form> </body> </html>
Servlet:
import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; @WebServlet("/Character") public class Character extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); System.out.println(request.getAttribute("text")); System.out.println("росто текст."); response.setContentType("text/html"); PrintWriter out = response.getWriter(); String isbn = "978-3-16-148410-0"; String[] isbnParts = isbn.split("-"); String html = "<Doctype html> <html><head><meta charset=\"utf-8\" /></head><body>"; html = html + "префикс EAN.UCC: " + isbnParts[0] + "\n"; html = html + "номер регистрационной группы: " + isbnParts[1] + "\n"; html = html + "номер регистранта: " + isbnParts[2] + "\n"; html = html + "номер издания: " + isbnParts[3] + "\n"; html = html + "контрольная цифра: " + isbnParts[4] + "\n"; html = html + "</body></html>"; System.out.println(html); out.println(html); } }