Servlet gets weird character with US International keyboard on Mac

怎甘沉沦 提交于 2019-12-03 16:40:30

That is the Mac OS Roman character encoding. (0xBB == -52.)

Some things to check:

  • getBytes(string, "UTF-8") and new String(bytes, "UTF-8").
  • The form should have been sent in UTF-8: response.setContentType("text/html; charset="UTF-8");. In a JSP <%@page pageEncoding="UTF-8"%>
  • <form action="..." accept-charset="UTF-8">

As all that did not help:

Set the request filtering in your web application (web-xml).


Encoding in pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>...</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <encoding>${project.build.sourceEncoding}</encoding>
    </configuration>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>...</version>
    <configuration>
        <encoding>${project.build.sourceEncoding}</encoding>
    </configuration>
</plugin>
...
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
chrisapotek

Ok, after a good 8 hours (serious!) it looks like the only way to get this working correctly is to do:

One of the problems was: bad maven build encoding compilation of class files.

export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
mvn clean install

AND:

   <%@page pageEncoding="UTF-8" %>

NOW:

There is no way knowable to pass the latter option in your pom.xml.

Here is a pending answer for that: enabling UTF-8 encoding for clojure source files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!