熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Struts 的漢字顯示問題終結解決方案

2013-11-23 20:36:46  來源: Java開源技術 

  看了網上的很多的解決方法似乎都很好但實際的操作中還是發現了很多的問題 試了很久才找到最終的解決方案
  
   主要是屬性文件的字符轉換問題具體步驟和檢測如下:
  
  ) 用一般的編輯器輸入所要顯示的漢字
  
  ) 使用Java JDK 下的nativeascii 詳細說明見
  
  
  
  nativeascii NativetoASCII Converter
  Converts a file with nativeencoded characters (characters which are nonLatin and nonUnicode) to one with Unicodeencoded characters
  SYNOPSIS
  nativeascii [options] [inputfile [outputfile]]
  
  DESCRIPTION
  The Java compiler and other Java tools can only process files which contain Latin and/or Unicodeencoded (\udddd notation) characters nativeascii converts files which contain other character encodings into files containing Latin and/or Unicodeencoded 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 nativeencoded characters
  
  encoding encoding_name
  Specify the encoding name which is used by the conversion procedure The default encoding is taken from System property fileencoding 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 JXmsm sets the startup memory to megabytes
  
  For encoding name you can reference:
  
  
  
  For chinese use normally use: GBK Big In Suns encoding document it is mentioned this conversion need: lib/rtjar or lib/charsetsjar These two file only can file Suns JRE package They cant find in Suns JDK package
  
  但是我在轉換的時候沒有這兩個文件似乎也沒有問題
  
  Example: nativeascii encoding GBK Inputfilename outputfilename
  
  轉換後的校驗
  
  nativeascii 會因為你的系統不同可能會有不同的轉換結果 如果發現問題你可以去:
  
   查詢依據目前的版本你可以找到
  
  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
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.