Java - Google App Engine - Problems with UTF-8 Encoding

I would like to add some accented characters in my ".jsp" and ".html", but when I write these characters with an accent in these files and load my pages:

  • è becomes à ©
  • "ç" becomes "ç"
  • "é" becomes "Ã"

Steps:

  • I configured Eclipse to create all files with UTF-8 encoding (I checked: all .jsp and .html files in the / src or / target folder are now UTF-8).

  • None of my .jsp or .html files (inside / src or / target) explicitly contain those "à ©", "ç", "Ã".

  • All my .jsp contain these lines at the beginning:

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <meta content="IE=edge" http-equiv="X-UA-Compatible" />
            <meta content="width=device-width, initial-scale=1" name="viewport" />
            <!-- ... -->
        </head>
    
  • I added these parameters to my appengine-web.xml:

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
        <!-- Added below -->
        <property name="file.encoding" value="UTF-8" />
        <property name="DEFAULT_ENCODING" value="UTF-8" />
    </system-properties>
    

, GAE, Exception:

<env-variables>
    <env-var name="DEFAULT_ENCODING" value="UTF-8" />
</env-variables>

GAE ():

, , . ( .)

, : DEFAULT_ENCODING = UTF-8

:

  • firebug , Content-Type text/html; charset=utf-8 .
  • Google <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> pom.xml, .

:

  • html- AJAX, , "é" "ç" . BalusC ( , response.setCharacterEncoding("UTF-8");, , ).
  • ( ), <%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %> <%@ page pageEncoding="UTF-8" %> , localhost, , Google Engine, , firebug Content-Type text/html; charset=utf-8, W3C Markup Validation :

    utf-8 (windows-1252)

:

  • Maven 3.2
  • IDE: Eclipse Luna
  • : Windows 7
+4
1

. .jsp , html : <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

0

Source: https://habr.com/ru/post/1618685/


All Articles