Answer the question
In order to leave comments, you need to log in
Why on the JSP page Russian characters are displayed as krakozyabry?
It happened to me that when internationalizing my web project, Russian characters are displayed as krakozyabry.
What I did:
1. I use properties-files in which I write text in the required language. You need to check that the text in these files is set to UTF-8.
It did not help. Move on.
2. Through Filter set encoding UTF-8 .
Create a filter in which we will set the UTF-8 encoding for request and response :
@WebFilter(filterName = "EncodingFilter", urlPatterns = {"/controller"})
public class EncodingFilter implements Filter {
private static final Logger LOGGER = LogManager.getLogger();
private final static String ENCODING_UTF_8 = "UTF-8";
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
LOGGER.info("Current encoding for request: {}, for response: {}.", servletRequest.getCharacterEncoding(), servletResponse.getCharacterEncoding());
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
request.setCharacterEncoding(ENCODING_UTF_8);
response.setCharacterEncoding(ENCODING_UTF_8);
LOGGER.info("Set encoding for request: {}, for response: {}.", request.getCharacterEncoding(), response.getCharacterEncoding());
filterChain.doFilter(request, response);
}
}
<!-- Encoding for jsp-pages to UTF-8 -->
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
<%request.setCharacterEncoding("UTF-8");%>
ÐлавнаÑ
РнаÑ
ÐонÑакÑÑ
Answer the question
In order to leave comments, you need to log in
Good afternoon!
I use properties files in which I write text in the desired language. You need to check that the text in these files is set to UTF-8
<head>
<meta charset="UTF-8">
</head>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question