get方式處理亂碼

2021-07-30 16:33:54 字數 807 閱讀 5021

get方式處理亂碼

用get方式傳中文的時候,瀏覽器會顯示%等亂碼,可以

用urlencode編碼,即可以在瀏覽器位址列顯示中文

function checkform()

亂碼處理:

發出請求jsp

parent.location.href="/web/conobj/buydetail.do?txt_conobj_key="+objkey+"&txt_contrade_kind="+contrade_kind+"&pick_types=a&jianjibuynum=0&order_prices="+

orderprice+"&cdlistkeyarrayfront="+""+"&buynum="+chatnum+"&artnflag="+ret.artnflag+"&cnt_key="+ret.cnt_key+"&msg="+encodeuricomponent(ret.msg);

後台:方法1 string msg2 =new string(msg.getbytes("iso-8859-1"), "utf-8");

到了這裡後變正常(貨物可購買量不足!)

model.addattribute("errorinfo", msg2);

方法2string msg2 =new string(msg.getbytes("iso-8859-1"), "utf-8");

this.request.setcharacterencoding("utf-8");

this.request.setattribute("errorinfo", msg2);

接收請求jsp:

購買失敗:$

終極解決GET方式中文亂碼

想重定向到錯誤提示頁面,並帶上錯誤資訊,實現方式是統一的controller異常處理器,攔截到異常,獲取異常響應型別是rest responsebody 還是頁面,若是頁面,則重定向到統一的錯誤頁面,帶上自定義異常的錯誤資訊,問題來了.若是中文錯誤資訊,在異常處理器中拿redirectattribu...

get請求方式和post請求方式亂碼問題

一 get請求方式亂碼 1 tomcat8版本伺服器已經自動配置好亂碼問題,所以get請求方式不會出現亂碼。2 tomcat7及以下版本get會出現亂碼問題,解決辦法是比post請求方式困難。主要有兩種方式解決 第一種 找到tomcat安裝包裡面conf底下的server.xml檔案 然後進入裡面找...

Post 和 get 請求亂碼問題處理

原始處理get post 請求亂碼 string newencoding new string params.getbytes iso 8859 1 utf 8 原理分析 post 處理亂碼方式 req.setcharacterencoding utf 8 resp.setheader conten...