JSP土耳其语字符问题

发布于 2024-10-19 00:32:39 字数 534 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沙与沫 2024-10-26 00:32:39

我看到两个潜在的原因:

  1. 您的编辑器没有将页面保存为 UTF-8。检查默认设置和/或“另存为”选项。
  2. 某些 JSP 中缺少 @page。它必须出现在所有 JSP 文件中,包括在内。

与具体问题无关,JSP 顶部的以下内容就足够了:

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

您放置在那里的剩余内容已经是(隐式)默认值。

I see two potential causes:

  1. Your editor didn't save the page as UTF-8. Check the default settings and/or the Save As option.
  2. The @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:

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

The remnant which you've put there are already (implicit) defaults.

放我走吧 2024-10-26 00:32:39

除了 DOCTYPE 声明之外,通常最好在文档 中包含一个元标记,如下所示:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

除此之外 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:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Beyond that BalusC's suggestion that all files involved need to be actually SAVED with UTF8 encoding is very important.

为你鎻心 2024-10-26 00:32:39

将此代码片段添加到您的 servlet 中:

request.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=utf-8");

Add this snippet into your servlet:

request.setCharacterEncoding("UTF-8");

response.setContentType("text/html; charset=utf-8");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文