强制 Eclipse 忽略字符编码属性

发布于 2024-12-27 02:03:38 字数 354 浏览 0 评论 0原文

我正在使用一个在 html 模板中使用动态字符编码的 Web 框架,如下所示:

<meta charset="${_response_encoding}">

问题是当我尝试在 Eclipse 中编辑此文件时,Eclipse 认为这是文字编码类型,因此拒绝打开文件,说:

“不支持的字符编码” 字符编码 此平台不支持“${_response_encoding}”。

有没有什么方法可以告诉 Eclipse 停止尝试变得“聪明”(因为它显然不是)而只是向我显示文本?我尝试过使用“打开方式...文本编辑器”,但结果仍然相同。

I'm working with a web framework that uses a dynamic character encoding in its html templates, like this:

<meta charset="${_response_encoding}">

The problem is when I try to edit this file in Eclipse, Eclipse thinks this is a literal encoding type, and thus refuses to open the file, saying:

"Unsupported Character Encoding" Character encoding
"${_response_encoding}" is not supported by this platform.

Is there any way to tell Eclipse to stop trying to be "smart" (because it plainly isn't) and just show me the text? I've tried using "Open With... Text Editor" but still same result.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

不及他 2025-01-03 02:03:38

更改 HTML 文件的内容类型:

转至 Windows ->偏好->一般->内容类型并更改您需要的所有文件扩展名的编码(将它们设置为 utf-8)。

Change the content type for HTML files:

Go to Windows -> preferences -> General -> Content types and change encoding (set them to utf-8) for all the file extensions you need.

醉城メ夜风 2025-01-03 02:03:38

选择“其他”,然后选择 UTF-8。然后你的模板将正常渲染。

Choose "Other" and then select UTF-8. Then your template will render as normal.

烏雲後面有陽光 2025-01-03 02:03:38

我遇到了类似的问题,除了在更改字符编码后尝试保存文档时收到错误消息。在输入非标准 charset 值之前,我通过在 Eclipse 中执行以下操作解决了该问题:

  • 将文件重命名为具有非 HTML 文件扩展名。
  • 使用 HTML 以外的编辑器打开该文件。
  • charset 值更改为您想要的非标准值。
  • 将文件重命名为原始扩展名。
  • 打开文件。
  • 按照按钮和提示将字符编码设置为文件的真实编码。

此后,该文件应该仍然可用,同时仍然具有非标准 charset 值。

I had a similar problem, except I was receiving the error message when trying to save the document after changing the character encoding. I resolved the problem by doing the following in Eclipse before putting in the non-standard charset value:

  • Rename the file to have a non-HTML file extension.
  • Open the file using an editor other than the HTML one.
  • Change the charset value to the non-standard value you want.
  • Rename the file to have the original extension.
  • Open the file.
  • Follow the buttons and prompts to set the character encoding to the real encoding of the file.

After this, the file should still be usable while still having the non-standard charset value.

不再让梦枯萎 2025-01-03 02:03:38

如果您让 Eclipse 将其视为 HTML 文件,那么它很聪明。这不是一个有效的编码名称。您是否尝试过仅模板化整个元标记?

If you're having Eclipse treat it like an HTML file, it is being smart. That's not a valid encoding name. Have you tried just templating the entire meta tag?

唠甜嗑 2025-01-03 02:03:38

(如评论中所述)在 Eclipse Indigo 中,打开文件时,您会看到“不支持的字符编码”消息以及“设置编码”按钮。使用该按钮来设置 UTF-8 编码。 Eclipse 不会更改 HTML 文件中的变量。

确实,这是在逐个文件的基础上完成的,但是,在我的项目中,我为每个屏幕导入相同的元头文件。实际上,我只有两个文件需要设置(已登录的文件和未登录的文件)。

(as mentioned in a comment) In Eclipse Indigo, when opening the file you see the Unsupported character encoding message along with a Set Encoding button. Us that button to set the UTF-8 encoding. Eclipse does not change the variable in the HTML file.

True, this is done on a file-by-file basis, however, in my project I import the same meta header file for every screen. Actually, I have only two files to setup (those that are logged in and those that are not).

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