URL亂碼 待續

2021-07-22 22:33:09 字數 797 閱讀 3242

如果不想在url中看到有明文,比如http://localhost:8080/template_1/login.action?user=張三

可以使用js的encodeuri的urldecoder.decode一起使用一起來把url加密下

(1)js在頁面上把資料var val = encodeuri(encodeuri("要傳到伺服器端的是值")); //呼叫2次encodeuri

href="recordmanager/test_js_decodeuri.action?params="+val

(注:encodeuri是js自帶的函式)

(2)伺服器端這樣

**如下:

system.out.println("轉換前:"+vstring);

string destring = urldecoder.decode(vstring, "utf-8");

system.out.println("轉換後:"+destring);

utf-8是和頁面上的編碼保持一致 比如:jsp頁面上 pageencoding="utf-8" 這裡就要是utf-8

在ie上右鍵編碼就能看到,如果jsp上pageencoding="utf-8" ie上右鍵編碼uncode(utf-8),如果jsp上pageencoding="gbk",那麼 ie上右鍵編碼(簡體中文gb2312)

url傳遞中文亂碼問題

通過鏈結傳遞引數值是中文時,會有2個問題 頁面採用utf 8格式 1 中文亂碼,在action接值時轉碼即可 使用new string str.getbytes iso 8859 1 utf 8 2 傳遞的中文引數後面還有其他引數,此時頁面 查詢其中 查詢條件search name 張三 後面npa...

URL亂碼重新編碼

定義判斷編碼的方法public static string getencoding string str catch exception exception encode iso 8859 1 try catch exception exception1 encode utf 8 try catch...

url請求引數亂碼問題

encoding org.springframework.web.filter.characterencodingfilter encoding utf 8 forceencoding true 但是get請求的引數還是有問題。具體原因可以參考 為了保證get資料採用utf8編碼,在server.x...