OData网址中的撇号问题 [英] Apostrophe issue in url with OData

查看:86
本文介绍了OData网址中的撇号问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用oData protocol在网址中添加过滤条件

I am using oData protocol which add the filter criteria in the url

例如/api/restaurants/getall?$filter=substringof('macdonald',Name)

我的问题是,当值具有撇号(macdonald's)时,它将破坏URL

My problem when the value has apostrophe like (macdonald's) it will break the url

如果我像macdonald%26那样用%26替换它,效果很好,但是通过添加s(macdonald%26s),该网址将无效

It works fine if I replace it with %26 like macdonald%26 but by adding s (macdonald%26s) the url will not work

有什么建议吗?

推荐答案

当在带引号的字符串中时,可以通过将其加倍来对单引号进行转义.因此,在您的情况下,它看起来像是麦克唐纳德".

When inside the quoted string a single quote can be escaped by doubling it. So in your case it would look like 'macdonald''s'.

这篇关于OData网址中的撇号问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆