一、若是是經過URL傳遞:----須要編碼兩次ajax
var searchText = this.searchText();
searchText = encodeURI(searchText);
searchText = encodeURI(searchText);
$.ajax({
type: 'GET',
url: $ctx + this.pageUrl + pageIndex + "&searchText=" + searchText,
data: '',
contentType: 'text/json,charset=utf-8',
dataType: 'json',
success: function(data) {
}
})
},json
後臺經過:this
String queryCon = request.getParameter("searchText");
if(queryCon != null && queryCon != ""){
queryCon=URLDecoder.decode(queryCon,"utf-8");
}編碼
反編譯一下就能夠獲取到傳遞的中文~~url
二、 直接經過ajax數據傳遞:只需編譯一次~spa
var searchText = this.searchText();
searchText = encodeURI(searchText);
$.ajax({
type: 'GET',
url: $ctx + this.pageUrl + pageIndex ,
data: {search:searchText },
contentType: 'text/json,charset=utf-8',
dataType: 'json',
success: function(data) {
}
})
},code
後臺直接獲取到傳遞的值,須要解碼一次:utf-8
String queryCon = search;
if(queryCon != null && queryCon != ""){
queryCon=URLDecoder.decode(queryCon,"utf-8");
}get