在 NetBeans 中将 JSP 保存为 UTF-8

发布于 2024-10-16 01:48:44 字数 521 浏览 2 评论 0原文

我从其他开发人员那里得到了一些 jsp 文件,现在需要使用它们。当我向文档添加任何 UTF-8 字符并想要保存文档时,NetBeans 会自动提供以 ISO-8859-1 格式保存的功能。

实际上我从 NetBeans 收到了这条消息:

index.jsp 包含字符 这可能会在过程中被损坏 转换为 ISO-8859-1 字符 放。您要保存文件吗 使用这个字符集? (是/否)

NB 没有为我提供任何其他选项,例如将文件保存为 UTF-8(因为它应该已经写入)。

我不知道如何将这些 jsp 文件保存在它们已经写入的字符集中。

并且不要告诉我,更改文件本身的内容(由于包含来自其他文件的标头等,这是无效的)是唯一的方法...

http://forums.netbeans.org/topic8750.html

i've got some jsp files from another developers and now need to work with them. When i add to the document any UTF-8 char and want to save the document, NetBeans automatically offers me saving in ISO-8859-1.

Actually i'm getting this message from NetBeans:

The index.jsp contains characters
which will probably be damaged during
conversion to the ISO-8859-1 character
set. Do you want to save the file
using this character set? (Yes/No)

NB didn't offer me any other option like saving the file as UTF-8 (as it should be already written in).

I don't know how to save those jsp files in the character set they are already written in.

And don't tell me, that changing the content of the file itself (which is uneffective due to including headers etc. from other files) is the only way...

http://forums.netbeans.org/topic8750.html

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

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

发布评论

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

评论(1

玻璃人 2024-10-23 01:48:44

首先;不要忘记考虑顶部的这一行:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

其次;
在 NetBeans 文件夹中有一个配置文件。应该有这样一行:

netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"

将其添加到该行末尾:

-J-Dfile.encoding=UTF-8 

第三:

NetBeans 实现项目编码设置。

要更改项目的语言编码:

  1. 右键单击​​“项目”窗口中的项目节点,然后选择“属性”。
  2. 在源下,从编码下拉字段中选择编码值。

编码至少影响:

* how non-ASCII characters are displayed in the editor window when you open files
* Java file compilation of sources containing non-ASCII identifiers, string literals, or comments
* textual search for international characters over the project 

从 NetBeans IDE 6.8 开始,您还可以指定运行时使用的编码。例如,当运行应用程序的操作系统的编码与项目的编码不同时,这会很有用。

要指定运行时使用的编码:

  1. 在项目的“文件”窗口中,打开 nbproject >私人> private.properties
  2. 将以下行添加到 private.properties 文件并保存更改:

runtime.encoding = <编码>

此编码将覆盖您项目的编码设置,并将在运行应用程序时使用。

一般来说,

*.properties files always use ISO-8859-1 encoding plus \uXXXX escapes. (International characters will be displayed natively in the editor but stored as an escape on disk.)
*.xml files and some *.html files can specify their own encodings, regardless of the project encoding. For such files, the IDE's editor ignores the project encoding. 

这些可能会对您有所帮助。

我使用的答案的来源:

链接1:http://forums.netbeans。 org/topic33.html

链接2:http://wiki.netbeans.org/FaqI18nProjectEncoding

Firstly; don't forget to consider this line at top:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

Secondly;
In the NetBeans folder there is a config file. There should be a line like that:

netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"

Add this to the end of the line:

-J-Dfile.encoding=UTF-8 

Thirdly:

NetBeans implements a project encoding setting.

To change the language encoding for a project:

  1. Right-click a project node in the Projects windows and choose Properties.
  2. Under Sources, select an encoding value from the Encoding drop-down field.

The encoding affects at least:

* how non-ASCII characters are displayed in the editor window when you open files
* Java file compilation of sources containing non-ASCII identifiers, string literals, or comments
* textual search for international characters over the project 

Starting from NetBeans IDE 6.8, you can also specify the encoding that will be used at runtime. For example, this can be useful when the encoding for the operating system on which the application will run is different from your project's encoding.

To specify the encoding to be used at runtime:

  1. In the Files window for your project, open nbproject > private > private.properties
  2. Add the following line to the private.properties file and save changes:

runtime.encoding = < encoding >

This encoding will override the encoding setting for your project and will be used when running your application.

In general,

*.properties files always use ISO-8859-1 encoding plus \uXXXX escapes. (International characters will be displayed natively in the editor but stored as an escape on disk.)
*.xml files and some *.html files can specify their own encodings, regardless of the project encoding. For such files, the IDE's editor ignores the project encoding. 

These may help you.

Sources for my answer that I used:

Link1: http://forums.netbeans.org/topic33.html

Link2: http://wiki.netbeans.org/FaqI18nProjectEncoding

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