看了網上的很多的解決方法
似乎都很好
但實際的操作中還是發現了很多的問題
試了很久才找到最終的解決方案
主要是屬性文件的字符轉換問題
具體步驟和檢測如下:
) 用一般的編輯器輸入所要顯示的漢字
) 使用Java JDK 下的native
ascii
詳細說明見
native
ascii
Native
to
ASCII Converter
Converts a file with native
encoded characters (characters which are non
Latin
and non
Unicode) to one with Unicode
encoded characters
SYNOPSIS
native
ascii [options] [inputfile [outputfile]]
DESCRIPTION
The Java compiler and other Java tools can only process files which contain Latin
and/or Unicode
encoded (\udddd notation) characters
native
ascii converts files which contain other character encodings into files containing Latin
and/or Unicode
encoded charaters
If outputfile is omitted
standard output is used for output
If
in addition
inputfile is omitted
standard input is used for input
OPTIONS
reverse
Perform the reverse operation: convert a file with Latin
and/or Unicode encoded characters to one with native
encoded characters
encoding encoding_name
Specify the encoding name which is used by the conversion procedure
The default encoding is taken from System property file
encoding
The encoding_name string must be taken from the first column of the table of supported encodings in the Supported Encodings document
Joption
Pass option to the Java virtual machine
where option is one of the options described on the reference page for the java application launcher
For example
J
Xms
m sets the startup memory to
megabytes
For encoding name you can reference:
For chinese use normally use: GBK
Big
In Sun
s encoding document
it is mentioned this conversion need: lib/rt
jar or lib/charsets
jar
These two file only can file Sun
s JRE package
They cant find in Sun
s JDK package
但是我在轉換的時候沒有這兩個文件似乎也沒有問題
Example: native
ascii
encoding GBK Inputfilename outputfilename
轉換後的校驗
native
ascii 會因為你的系統不同
可能會有不同的轉換結果
如果發現問題
你可以去:
查詢
依據目前的版本
你可以找到
East Asian Scripts
> Han ideographs
>Unified CJK ideographs(
M)
這個文件
下載後
你用PDF reader 的search功能找到你要轉換的漢字
比較轉換後的
字符是否正確
比如
我
在轉換後為 /u
所有的JSP文件采用UTF
格式遍寫
並在文件頭強制:
<%@ page contentType=
text/html;charset=UTF
language=
java
%>
這樣你的問題就解決了
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28754.html