WebLogic8.1の中国語問題解決方法


Webアプリケーションにおける中国語の問題
1.静的ページ中国語情報が正しく表示されない
ブラウザ側は中国語が正しく表示されないのを見て、まずブラウザが中国語をサポートしているかどうか、ブラウザのコードが正しく設定されているかどうかを確認しなければならない.静的ページの中国語情報の正確な表示を保証するためにHTMLの部分で追加できます.
<meta http-equiv="Content-Type" content="text/html" charset="GBK">

2.JSPの中国語提示メッセージが正しく表示されない
JSPの中国語プロンプトが正常に表示されないのは、WebLogicのデフォルト文字セットが中国語文字セットではないため(Weblogic 8.1ではsetlocal、Weblogic 7.0 sp 3、sp 4はUTF-8)です.そのため、JSPページに文字セットを設定し、以下のスクリプトを加えることができます.
<%@ page contentType="text/html; charset=GBK"%>
この方法はJSPページ毎に設定が必要であり、以下の方法はすべてのjspページに対して設定が一般的である.
3.JSPファイルのヒント情報を正しくコンパイルできない
JSPファイルのヒント情報は正しくコンパイルされ、weblogic.xmlでは、上記の2つ目の問題を解決するスクリプトを設定します.
<jsp-descriptor>
<jsp-param>
<param-name>compileCommand</param-name>
<param-value>javac</param-value>
</jsp-param>
<jsp-param>
<param-name>compilerSupportsEncoding</param-name>
<param-value>true</param-value>
</jsp-param>
<jsp-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</jsp-param>
</jsp-descriptor>
4. JSPファイル間で中国語データが正しく伝達されない
JSPファイル間で中国語のデータを正しく伝達できない場合は、2つの方法で解決することができる.
その1:web.xmlには、次のスクリプトが追加されます.
<context-param>
<param-name>weblogic.httpd.inputCharset./*</param-name>
<param-value>GBK</param-value>
</context-param>

二つ目はweblogicです.xmlには、次のスクリプトが追加されます.
<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>GBK</java-charset-name>
</input-charset>
</charset-params>
もちろんこの問題は自分でjavaを使うこともできます.net.URLEncoderとjava.net.URLDecoderは中国語を処理します.
以上はデータベース操作には関与していないので、文字化けしが発生した場合、逐一分析し、
必ず問題の所在を見つけることができる.また、WebLogicアプリケーションサーバが存在するオペレーティングシステムの文字セットを修正し、中国語がサポートされていることを確認する必要があるかもしれません.
ファイル名とディレクトリの中国語の問題
もしあなたのファイル名やディレクトリが中国語だったらどうしますか?上記の方法ではあなたの問題を解決できません.この場合javaを使用する必要がある.net.URLEncoder符号化例を挙げるとtest.jspでは、ハイパーリンクを./テスト/テスト.jsp、そう書いてもいいです.

">go

如果JDBC的中国语问题以上的方法不能解决文字化问题的话,可能是JDBC操作中的错误。ここでは、Oracle 9 Iを例に、jdbcにおける中国語の問題について説明する.首先检索数据基础.select * from v where parameter='NLS_CHARACTERSET'; 得到数据ベース的文字套装,如果ZHS 16 GBK的话,JDBC的动作不需要特朗斯科德.US 7 a scii的情况下,特朗斯科德或相关构成需要。以下说明使用不同的数据显示器的例子.1.使用Thin Driver的使用Thin Driver的情况下,在咨询数据ベース的时候,文字セットをISOからGBKへ,在数据ベース上写入时,文字セットをGBKからISOへ変更する必要がある.列举例子插入唱片Connection conn=null; PreparedStatement pstmt = null; try { String strSql=「insert into tabA(A,B)values('1111','王超')」; conn=ds.getConnection(); strSql = new String(strSql.getBytes("GBK"), "ISO-8859-1"); pstmt = conn.prepareStatement(strSql); pstmt.executeUpdate(); } catch (Exception e) { //logger.error(e, e); } finally { disconn(conn, pstmt); }请咨询唱片.Connection conn=null; PreparedStatement pstmt = null; ResultSet rs=null; try { String strSql="select B from tabA where A='1111'"; conn=ds.getConnection(); strSql = new String(strSql.getBytes("GBK"), "ISO-8859-1"); pstmt = conn.prepareStatement(strSql); rs=pstmt.executeQuery(); String strB; if (rs.next()){ strB=new String(rs.getString(1) .getBytes("ISO-8859-1"), "GBK"); } catch (Exception e) { //logger.error(e, e); } finally { disconn(conn, pstmt, rs); }在这里,我建议基于文字套图来判断oracle文字套图.为了提高应用程序的移植性,你会转发代码吗?2.直接使用OCI Driver的使用WebLogic提供的driver,在连续游泳池的构成时设定Properties项目.weblogic.codeset=GBK,如下图:/blog/images/weblogic.如果采用gif上记的2种方法,也没有解决文字化的话,请检查一下只有边鄙的字是非常表示吗?在这种情况下需要使用oracle的文字套装包装:nls_charset12.zip,この包装をWebLogic classpathに追加する.我认为在暗号化中的中国语问题中国语信息不包含暗号化和复号化中,可以实现很多阿尔戈里斯姆.但是,因为中国语是2个字,所以普通的黑号阿尔戈里斯姆不能在1次的黑号化后复原。由于用BASE 64的中国语信息符号化并暗号化,可以简单地解决这个问题.当然,复号后也需要在BASE 64复号。例如下一.String pw=「中国語」 System.out.println(pw); pw=new sun.misc.BASE64Encoder().encode(pw.getBytes()); System.out.println(pw); //暗号化 String pw1=encode(pw); System.out.println(pw1); //解読 String pw2=decode(pw1); System.out.println(pw2); byte[] bt=new sun.misc.BASE64Decoder().decodeBuffer(pw2); pw2=new String(bt); System.out.println(pw2);以下,使用kaiser阿尔戈里斯姆而被暗号化的完全苏斯科德.package test; /** *暗号化クラス */ import java.lang.Math; public class SecurityTest { interface Constants{ public static final int INT_PRIM_NUMBER = 95; public static final int INT_RETURN_LOOP = 94; } /** * SysBean constructor comment. */ public SecurityTest() { super(); } /** *復号方法 * zhg *作成日(2002-12-15 10:17:08) *strCodeで復号する文字列 *復号後の文字列 * 1.0 */ public static String decode(String strCode) { String strOriginal; int intRnd; String strRnd; int intStrLen; String strDecodeMe = ""; if (strCode.equals("")) return strDecodeMe; intStrLen = strCode.length() - 1; strRnd = strCode.substring(intStrLen / 2, intStrLen / 2 + 1); intRnd = strRnd.hashCode() - new SecurityTest().startChar(); strCode = strCode.substring(0, intStrLen / 2) + strCode.substring(intStrLen / 2 + 1, intStrLen + 1); strOriginal = new SecurityTest().loopCode( strCode, Constants.INT_RETURN_LOOP - intRnd); strDecodeMe = strOriginal; return strDecodeMe; } /** *暗号化方法暗号化されたサイクル数をランダムに取得することで、暗号化されるたびに得られる秘密文が異なる * zhg *作成日(2002-12-15 10:17:08) *strOriginalで暗号化する文字列 *暗号化された文字列 * 1.0 */ public static String encode(String strOriginal) { String strCode; int intRnd; char rnd; int intStrLen; String strCodeMe = ""; if (strOriginal.equals("")) return strCodeMe; //2から93までの間の直数、すなわち同じ原文で93種類の異なる秘文が得られる可能性がある intRnd = (int) (Math.random() * (Constants.INT_RETURN_LOOP - 2) + 2); strCode = new SecurityTest().loopCode(strOriginal, intRnd); //乱数のオフセット暗号化 rnd = (char) (intRnd + new SecurityTest().startChar()); intStrLen = strCode.length(); strCodeMe = strCode.substring(0, intStrLen / 2) + rnd + strCode.substring(intStrLen / 2, intStrLen); if (strCodeMe.indexOf("'") >= 0) return encode(strOriginal); else return strCodeMe; } //ベースのシーザーアルゴリズムで、各ビットにオフセットを追加 private String kaiserCode(String strOriginal) { int intChar; String strCode; int i; int intStrLen; int intTmp; intStrLen = strOriginal.length(); strCode = ""; for (i = 0; i < intStrLen; i++) { intChar = strOriginal.substring(i, i + 1).hashCode(); intTmp = intChar - this.startChar(); intTmp = (intTmp * Constants.INT_PRIM_NUMBER + i + 1) % this.maxChar() + this.startChar(); strCode = strCode + (char) (intTmp); } return strCode; } //シーザーアルゴリズムを一定回数繰り返し呼び出した後、原文を取得できる private String loopCode(String strOriginal, int intLoopCount) { String strCode; int i; strCode = strOriginal; for (i = 0; i < intLoopCount; i++) strCode = this.kaiserCode(strCode); return strCode; } public static void main(String[] args) throws Exception { String pw=「中国語」 System.out.println(pw); pw = new sun.misc.BASE64Encoder().encode(pw.getBytes()); System.out.println(pw); //暗号化 String pw1 = encode(pw); System.out.println(pw1); //解読 String pw2 = decode(pw1); System.out.println(pw2); byte[] bt = new sun.misc.BASE64Decoder().decodeBuffer(pw2); pw2 = new String(bt); System.out.println(pw2); } private int maxChar() { String str1 = "~"; String str2 = "!"; return str1.hashCode() - str2.hashCode() + 1; } private int startChar() { String str1 = "!"; return str1.hashCode(); } } 总结本文列举了在WebLogic中经常见到的几个中国语问题的解决方法。希望使用读者.必须注意的是,GBK文字套图比GB 2312的文字live更大,GB 2312也有不太使用的文字.应该使用GBK文字套装.