How to set JSTL Core String character encoding

Viewed 159

I have a problem to display German special characters.

My Java Bean tests some user input and fills an error message string if there is an error. In the jsp I access the Bean's error message if there is one using JSTL Core like so:

    <c:if test="${MyBean.errorMsg != ''}">
        <c:out value="${MyBean.errorMsg}" />
    </c:if>

The error message is: "Alle Felder müssen ausgefüllt werden."; It is displayed in Chrome as follows: "Alle Felder müssen ausgefüllt werden."

  • I tried including the following in the JSP:

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    

    which worked for all text I output directly in JSP but not via the prefix c.

  • I tried to set the JSTL character encoding to UTF-8 via FTM:

    <%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>
    <fmt:requestEncoding value = "UTF-8" />
    

    Which did not solve it.

  • I put the following in the Controller Servlet that handles the request:

    request.setCharacterEncoding("UTF-8");

    This did not have any effect.

0 Answers
Related