如何将特殊字符作为URL中的参数之一传递。 [英] How to pass special character as one of the parameter in URL.?

查看:106
本文介绍了如何将特殊字符作为URL中的参数之一传递。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将特殊字符作为URL中的参数之一传递。?



并使用GET方法在休息客户端访问它



我尝试了什么:



我的剧本



< script>

类型:GET;



网址:http:// localhost:24844 / CustomerService .svc / AuthenticateUser /+ $('#sender-email')。val()+/+ $('#user-pass')。val();



ContentType:application / json; charset = utf-8;



数据类型:json;



ProcessData:true;







< / script>



服务



[OperationContract]

[WebInvoke(方法=PUT) ,ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json,UriTemplate =AuthenticateUser)]

用户V alidateUser(User _objUser);

解决方案

('#sender-email')。val()+/+


('#user-pass')。val();



ContentType:application / json; charset = utf-8;



数据类型:json;



ProcessData:true;







< / script>



服务



[OperationContract]

[WebInvoke(Method =PUT,ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json ,UriTemplate =AuthenticateUser)]

用户验证用户(用户_objUser);


尝试使用

1. encodeURI() [ ^ ]

2. decodeURI() [ ^ ]



示例:

网址: encodeURI   http:// localhost:24844 / CustomerService.svc /的authenticateUser / + 

How to pass special character as one of the parameter in URL.?

and access it in rest client using GET Method

What I have tried:

my script

<script>
Type : "GET";

Url : "http://localhost:24844/CustomerService.svc/AuthenticateUser/"+$('#sender-email').val() +"/"+ $('#user-pass').val();

ContentType : "application/json; charset=utf-8";

DataType : "json";

ProcessData : true;



</script>

service

[OperationContract]
[WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "AuthenticateUser")]
User ValidateUser(User _objUser);

解决方案

('#sender-email').val() +"/"+


('#user-pass').val();

ContentType : "application/json; charset=utf-8";

DataType : "json";

ProcessData : true;



</script>

service

[OperationContract]
[WebInvoke(Method = "PUT", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "AuthenticateUser")]
User ValidateUser(User _objUser);


Try using
1. encodeURI()[^]
2. decodeURI()[^]

Example:

Url : encodeURI("http://localhost:24844/CustomerService.svc/AuthenticateUser/"+


这篇关于如何将特殊字符作为URL中的参数之一传递。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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