坐在我的网络应用程序中,我遇到了一些奇怪的事情。 <a href="changeLocale?language=ru">Русский</a>
并未按原样显示,似乎在8859中显示了单词Русский
。这是整个应用程序中唯一用内嵌Cyrlic符号编写的位置。我有一个用IDEA编写和创建的.jsp文件(我已经检查了文件的编码,它是UTF-8),同时使用.jspf和UTF-8,并且在<footer/>
标签中设置了以上一行。我已经设置了页面编码,已经设置了,已经在web.xml中将Tomcat的设置设置为UTF-8。
footer.jspf
<footer class="footer">
<div class="container">
<span class="text-muted">All rights and all lefts reserved.</span>
<a href="changeLocale?language=en">English</a>
<a href="changeLocale?language=ru">Русский</a>
</div>
</footer>
main.jsp
<%@ include file="WEB-INF/jspf/taglib.jspf" %>
<html>
<title>
<fmt:message key="welcome"/>
</title>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<%@ include file="WEB-INF/jspf/style.jspf" %>
</head>
<body>
<%@ include file="WEB-INF/jspf/header.jspf" %>
<div class="album py-5 bg-light">
<%-- some body ---%>
</div>
<%@ include file="WEB-INF/jspf/footer.jspf" %>
<script>
<%-- some script --%>
</script>
</body>
</html>
似乎所有内容都设置为UTF-8,但该行不在UTF-8中。 locale.properties
文件中的每个其他用JSTL编写的单词都可以正常运行(<fmt:message key="welcome"/>
有效)。我已经测试了另一个带有两个meta
标签(content type
和charset
)的纯HTML文件,并且在这里可以正常工作。甚至从<meta http-equiv="content-type" content="text/html; charset=utf-8">
复制了style.jspf
,但这无济于事。我在做什么错?
我相信您还需要指定设置页面字符编码的页面指令。尝试将以下内容放在页面顶部:
<%@ page contentType="text/html; charset=UTF-8" %>