JSP土耳其语字符问题
我有一个 jsp 页面在 jboss 4.2.2 服务器下运行。
页面的结构是这样的:
包含head(head写在另一个页面上,就像aspx中的母版页一样。)
(正文(问题出现的地方))
包括脚(脚也写在另一个页面中。)
头页面包含编码和元标记:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
当我在页面中写入诸如 şğĞіÇçÖ
(土耳其语)之类的字符时,字符显示为“?” (问号)我应该怎样做才能避免这种行为?
如何才能让jsp页面中的文字显示出来呢?
I have a jsp page running under jboss 4.2.2 server.
The structure for the page is something like this:
include head ( head is written on another page, like masterpage in aspx. )
(body ( where the problem appears ))
include foot ( foot is also written in another page. )
The head page contains the encoding and meta tags:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
When I write characters in the page such as şğĞİÇçÖ
(Turkish) the characters are shown as "?" ( question mark ) what should I do to avoid this behavior?
How can I have the text shown just as writen in the jsp page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我看到两个潜在的原因:
@page
。它必须出现在所有 JSP 文件中,包括在内。与具体问题无关,JSP 顶部的以下内容就足够了:
您放置在那里的剩余内容已经是(隐式)默认值。
I see two potential causes:
@page
is missing in some of the JSPs. It has to be present in all JSP files, also the includes.Unrelated to the concrete problem, the following in top of JSP was been enough:
The remnant which you've put there are already (implicit) defaults.
除了
DOCTYPE
声明之外,通常最好在文档中包含一个元标记,如下所示:
除此之外 BalusC的建议,所有涉及的文件实际上需要使用UTF8编码保存重要的。
In addition to the
DOCTYPE
declaration it is usually a good idea to include a meta tag in the document<head>
like this:Beyond that BalusC's suggestion that all files involved need to be actually SAVED with UTF8 encoding is very important.
将此代码片段添加到您的 servlet 中:
Add this snippet into your servlet: