How to solve Chinese display garbled problems in WebLogic Server

xiaoxiao2021-03-06  58

Due to operating systems, browsers, databases, the character sets in JVM are different. Applications based on WebLogic Server developed Chinese display garbled issues, in fact, Web applications running on WebLogic Server have a lot of settings related to character sets, below To make a summary, in order to properly handle Chinese, it is best to set these settings.

1. Add <% @ page contentType = "text / html; charset = GBK"%> Specify the character set adopted by the JSP.

2. Add: encoding encoding GBK specified The character set in the JSP file, in the JSP file <% @ Page ContentType = "text / html; charset = GBK"%> overwrites this setting

3. Add compilersupportsencoding true True, specify that when compiling the JSP file, use the <% @ page contentType = "text / html; charset = GBK"%> or defined in the JSP file to perform the character set defined in the encoding parameter defined in the jsp file. Encoding, if false, encoding the default specified character set in the JVM.

4. WebLogic Server needs to convert the data in HTTP Request (Get and POST) from its original encoding to Unicode so that the Java Servlet API is processed. For this conversion, WebLogic Server needs to know the encoding mode of the data in the HPPT Request. This can be set in WebLogic.xml / GBK < / Input-charset>

5. From the Chinese display from the Oracle database, in this case, if the database uses the Chinese character set, and use Type 2 JDBC Driver, you can add WebLogic.codeset = GBK properties to solve this problem. The code is as follows: java.util.properties PROPS = new java.util.properties (); Props.Put ("WebLogic.codeEt", "GBK"); Props.Put ("User", "Scott"); Props.put ("Password", "Tiger"); String ConnectURL = "JDBC: WebLogic: Oracle"; Driver MyDriver = (DRIVER) Class.Forname ("WebLogic.jdbc.oci.driver). NewInstance (); connection conn = myDriver .connect (connectURL, PrOPS); 6. If you use the WTC call Tuxedo, you cannot display Chinese in the JSP page, you must make the NLS_LANG environment variable on the server installed with Tuxedo, the same settings as the set of character sets in the database. If the character set in the background Oracle database is set to Simplified Chinese_China.zhs16GBK, then the NLS_LANG environment variable on the Tuxedo application server should be set to: export nls_lang = "simplified Chinese_china.zhs16GBK"

转载请注明原文地址:https://www.9cbs.com/read-112698.html

New Post(0)