oData 中以下查询中的 & 符号是如何处理的?
/vendordataservice.svc/vDataMapper_SourceMapVendor?&$filter=startswith(ParentName,'AT&T')&$top=7&$skip=0
我正在使用 EF3.5 和 SQL2008。当我将其发送到我的 oData 服务时,我没有收到任何数据。
不要使用“JavaScript String Replace() 方法”。它将替换第一次出现的特殊字符。如果过滤参数中出现两次相同的特殊字符,则过滤失败。所以使用正则表达式来替换字符。
function replaceSpecialCharacters(attribute) {
// replace the single quotes
attribute = attribute.replace(/'/g, "''");
attribute = attribute.replace(/%/g, "%25");
attribute = attribute.replace(/\+/g, "%2B");
attribute = attribute.replace(/\//g, "%2F");
attribute = attribute.replace(/\?/g, "%3F");
attribute = attribute.replace(/#/g, "%23");
attribute = attribute.replace(/&/g, "%26");
return attribute;
}
另请注意,因为替换内容还包含%
then %
本身应该在一开始就被替换
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)