欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
WebLogic8.1的中文問(wèn)題解決方法
由于近來(lái)論壇中經(jīng)常碰到中文問(wèn)題的咨詢(xún),所以在下在百忙之中趕出這篇文章,希望能給大家一點(diǎn)指引.如有紕漏,請及時(shí)指正!

Web應用中的中文問(wèn)題
1. 靜態(tài)頁(yè)面中文信息不能正確顯示
瀏覽器端看到中文不能正確顯示,首先應該檢查瀏覽器是否支持中文,瀏覽器的編碼是否設置正確.為保證靜態(tài)頁(yè)面中文信息正確顯示可以在HTML <HEAD> 部分增加:
<meta http-equiv="Content-Type" content="text/html" charset="GBK">
2. JSP里的中文提示信息不能正確顯示
JSP里的中文提示信息不能正常顯示,最直接的原因是WebLogic的默認字符集不是中文字符集(Weblogic8.1里是setlocal,Weblogic7.0sp3,sp4為UTF-8),因此可以在JSP頁(yè)面中設置字符集,加入如下腳本:
<%@ page contentType="text/html; charset=GBK" %>
這種做法需要對每個(gè)JSP頁(yè)面進(jìn)行設置,下面的做法針對所有的jsp頁(yè)面進(jìn)行設置,比較通用.
3. JSP文件中的提示信息不能正確編譯
JSP文件中的提示信息正確編譯,可以在weblogic.xml里設置如下腳本,同時(shí)也可以解決上面說(shuō)的第二個(gè)問(wèn)題:
<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文件之間不能正確傳遞中文數據,可以有兩種方法解決.
其一:在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>
當然這種問(wèn)題也可以自己用java.net.URLEncoder和java.net.URLDecoder來(lái)處理中文.
以上都沒(méi)有涉及到數據庫操作,所以當出現亂碼時(shí),逐一分析,
必能找到問(wèn)題所在.另外可能還需要修改WebLogic應用服務(wù)器所在操作系統的字符集,確保支持中文.

文件名和目錄中的中文問(wèn)題
如果你的文件名或者目錄是中文怎么辦呢?上面提到的方法不能解決你的問(wèn)題了.這時(shí)需要使用java.net.URLEncoder編碼.舉個(gè)例子,在test.jsp里,你需要提供一個(gè)超鏈接到 ./測試/測試.jsp,你可以這么寫(xiě):
<p><a href="<%=java.net.URLEncoder.encode("./測試/測試.jsp")%>">go</p>

JDBC中的中文問(wèn)題
如果以上的方法還不能解決你的亂碼問(wèn)題,那么可能是JDBC操作中的失誤.這里以Oracle9I為例來(lái)說(shuō)明jdbc中的中文問(wèn)題.首先查詢(xún)數據庫:
select * from v where parameter=‘NLS_CHARACTERSET‘;
得到數據庫的字符集,如果ZHS16GBK,則JDBC的操作不需要轉碼;如果是us7ascii,則需要轉碼或者作相關(guān)配置.下面以使用不同的數據庫驅動(dòng)程序為例來(lái)介紹.
1. 使用Thin Driver
如果使用Thin Driver,那么需要在查詢(xún)數據庫的時(shí)候將字符集由ISO轉換為GBK,寫(xiě)入數據庫的時(shí)候將字符集由GBK轉換為ISO.
舉個(gè)例子:
插入一條記錄:
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);
}
查詢(xún)一條記錄:
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,在配置連接池時(shí)設置Properties屬性:
weblogic.codeset=GBK,如下圖所示:

當你采用了上面的兩個(gè)方法還不能解決你的亂碼時(shí),你檢查一下是否僅僅是孤僻字不能正常顯示呢?這種情況你需要使用oracle的字符集包: nls_charset12.zip,將該包加入到WebLogic classpath中.

加密中的中文問(wèn)題
對于不含中文信息的加密和解碼,我想有很多算法可以實(shí)現.但由于中文為兩個(gè)字符,普通的加密算法在一次加密一次解密之后無(wú)法復原.采用BASE64對中文信息進(jìn)行編碼后再加密可以輕松解決這個(gè)問(wèn)題.當然解密之后同樣需要用BASE64解碼.示例如下:
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);
下面給出一個(gè)完整的使用kaiser算法加密的源代碼:
package test;
/**
* 加密類(lèi)
*/
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
* 創(chuàng )建日期 (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;
}
/**
* 加密方法.隨機取得加密的循環(huán)次數,使得每次加密所得的秘文會(huì )有所不同
* zhg
* 創(chuàng )建日期 (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;
}
//循環(huán)調用凱撒算法一定次數后,可以取得原文
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中經(jīng)常碰到的一些中文問(wèn)題的解決方法.希望讀者能夠靈活運用.需要提醒的是GBK字符集比GB2312的字庫大,有些不常用字在GB2312里是沒(méi)有的.所以請盡量使用GBK字符集.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
解決web服務(wù)器各種應用的亂碼問(wèn)題,歡迎補充和討論
struts,ajax亂碼解決方案
JSP?實(shí)現柱狀圖,餅狀圖
采用HTTP協(xié)議上傳文件實(shí)現(java)
JSP 文件下載的相對完整代碼(解決中文問(wèn)題, Weblogic 異常)
JAVA面試試題集
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久