我有一个 index.html 文件:
<!doctype html>
<html lang="fr" class="no-js fontawesome-i2svg-active fontawesome-i2svg-complete">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Annuaire Téléphonique</title>
...
我将它部署到由 Tomcat 9.0.35 服务的战争中。问题是在浏览器中,重音是这样的:“Annuaire Téléphonique”
我发现Tomcat服务的内容类型是假的:
- curl -v http://127.0.0.1:10000/ -> Content-Type: text/html;charset=ISO-8859-1
每个 Tomcat 配置都配置为 UTF-8。我的 Linux bash 定义 LANG=UTF-8,Tomcat 以 -Dfile.encoding=UTF-8 启动
我还发现,在询问表单 index.html 时,tomcat 没有指定编码,这对我来说是完美的,因为 index.html 本身包含 UTF-8 的 Content-Type 元数据,浏览器正确显示重音
- curl -v http://127.0.0.1:10000/index.html -> 内容类型:text/html
问题是:
- 为什么 index.html 作为欢迎文件(http://127.0.0.1:10000/)被作为 ISO-8859-1 服务?
- 它如何用作 UTF-8 ?(AddDefaultCharsetFilter UTF-8 没有帮助)
谢谢你的帮助