例子如下:
在js中 用encodeURI()对中文转码:
$(this).tree('options').url = encodeURI(encodeURI("../CountryStaManager/GetCountry?city=" + “中文”));
传到后台,用.net的 System.Web.HttpUtility.UrlDecode 转回中文:
public string GetCountry(string city)
{
city = System.Web.HttpUtility.UrlDecode(city);
}
本文介绍了一种使用JavaScript的encodeURI方法对中文进行编码,并通过.NET的System.Web.HttpUtility.UrlDecode方法进行解码的方法。该方法适用于前后端分离的应用场景,确保中文字符能够正确传递。
1544

被折叠的 条评论
为什么被折叠?



