如果网址有"#" $ http.post网址正在被删除

时间:2017-09-12 09:43:59

标签: angularjs rest http-post

我有一个Rest API:/myApp/fetchData/User-Name/Password。用户名和密码将根据请求进行更改。

当我像这样打电话给上面的restapi时

/myApp/fetchData/srikanth/Abcdef#g123

请求是这样的:

/myApp/fetchData/srikanth/Abcdef

基本上,URL文本已从#字符中删除。有什么方法可以解决吗?

谢谢, SRIKANTH。

1 个答案:

答案 0 :(得分:0)

在URI中#触发"fragment"的开头,并结束路径。片段通常指定路径标识的资源的一部分。

当您从客户端发布请求时,您必须escape special characters。您的请求应该是:

/myApp/fetchData/srikanth/Abcdef%23g123

转义网址有不同的方式,例如JS中的encodeURIencodeURIComponent功能。例如,您可以这样做:

var request = "/myApp/fetchData/srikanth/" + encodeURIComponent("Abcdef#g123");

然后服务器必须解码回原始请求。

但是:你确定以这种方式发送密码是一个很好的解决方案吗?