客户端用js函数encodeURI()对中文字符进行两次编码,服务器端采用URLDecoder类对客户端传输过来的中文字符进行UTF-8格式的解码。
客户端代码:
$.ajax({
type: "post",
url: "../?id=" + encodeURI(encodeURI($("张三风")),
success: function (msg) {
alert(msg);
}
});
$.ajax({
type: "post",
url: "createNewGroup.action",
data:"name="+encodeURI(encodeURI("张三")),
success: function(msg){
alert(msg);
}
});
服务器端对接收到的值进行解码Server.UrlDecode(),服务器端代码:
public string IsThisMemberName(string id) {
string name = Server.UrlDecode(id);
return name;
}
decodeURI 方法:返回一个已编码的统一资源标识符 (URI) 的非编码形式。function decodeURI(URIstring : String) : String
decodeURIComponent 方法:返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。
function decodeURIComponent(encodedURIString : String) : String
BTW:C#中对URL编码的方法。。。
编码:Server.UrlEncode(string)
解码:Server.UrlDecode(string) 前面三种客户端编码都可以用这个方法在后台解码。
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)