将JSP作为UTF-8保存在NetBeans中 [英] Saving JSP as UTF-8 in NetBeans

查看:201
本文介绍了将JSP作为UTF-8保存在NetBeans中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些jsp文件从另一个开发人员,现在需要与他们合作。当我添加到文档任何UTF-8字符,并要保存文档,NetBeans自动提供我保存在ISO-8859-1。

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.

实际上来自NetBeans的此邮件:

Actually i'm getting this message from NetBeans:


index.jsp包含字符
,它可能会在
转换为ISO-8859-1字符
设置。是否要使用此字符集保存文件
? (是/否)

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没有提供任何其他选项,例如将档案储存为UTF-已经写入)。

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

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

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

推荐答案

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

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

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

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

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"

将此添加到行末:

-J-Dfile.encoding=UTF-8 

第三:

NetBeans实现项目编码设置。

NetBeans implements a project encoding setting.

要更改项目的语言编码:

To change the language encoding for a project:


  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开始,还可以指定将在运行时使用的编码。例如,当应用程序运行的操作系统的编码与项目的编码不同时,这将非常有用。

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. 在项目的文件窗口中,打开nbproject> private> private.properties

  2. 将以下行添加到private.properties文件并保存更改:

runtime.encoding =< encoding>

runtime.encoding = < encoding >

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

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

一般情况下,

*.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. 

这些可能会帮助你。

em>我使用的回答来源:

Sources for my answer that I used:

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

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

这篇关于将JSP作为UTF-8保存在NetBeans中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆