导航:
论坛 -> Web应用开发
斑竹:bodies
作者:
2018/8/4 9:27:57
标题:
如何实现浏览器访问delphi的datasnap rest函数时传递多个参数?
浏览:2366
加入我的收藏
楼主:
如果是利用http实现C/S连接时时,多参数没有问题可以正常实现,但是采用B/S浏览器访问时只能传递一个参数. 请教哪位达人提供一个浏览器访问传递多个参数的思路. 万分感谢!! 代码: unit ServerMethodsUnit1: function TServerMethods1.Echo(Value: string): string; begin Result := Value; end; function TServerMethods1.fun001(p1, p2: string): string; var i: Integer; begin i := Pos(p2, p1); if i>1 then Result := p1.Substring(0, i-1) else if i=1 then Result := p1.Substring(i+Length(p2), 1000) else Result := ''; end; 浏览器访问: http://localhost:8888/datasnap/rest/ServerMethods1/echo/abc 浏览器显示{result:abc} 浏览器访问: http://localhost:8888/datasnap/rest/ServerMethods1/fun001/abcdefg,cd 浏览器显示{result:}
----------------------------------------------
-
作者:
2018/8/4 10:02:24
1楼:
一般URL多个参数都是采用类似 http://xxx/yyy?param1=value1¶m2=value2这样的形式吧?没用DataSnap做过东西,不清楚其所支持的具体方法。
----------------------------------------------
-广袤璀璨的银河,永无止境的梦想(梦无止境游银河) 博客挂了……
作者:
2018/8/4 17:31:22
2楼:
可以把多个参数组装成json上传
----------------------------------------------
-
作者:
2018/8/4 17:33:43
2楼:
rest无外乎通过http的get或post方法调用。 datasnap rest也是如此。 浏览器调rest是通过get方法。 get就是拼url,如下: http://192.168.1.222:5566/query?accountno=1&sql=select top 10 * from t2
----------------------------------------------
中间件QQ群: 92449782 博客: http://www.cnblogs.com/hnxxcxg/
作者:
2018/8/5 9:50:57
3楼:
https://www.cnblogs.com/cb168/p/5366775.html 这里有
----------------------------------------------
-
作者:
2018/8/5 10:25:43
4楼:
简单参数通过url拼接,复杂的就用xml,json
----------------------------------------------
-
作者:
2018/8/7 9:32:36
5楼:
地址改成如下就可以啊!: http://localhost:8888/datasnap/rest/ServerMethods1/fun001/abcdefg/cd 参数之间的逗号改成/
----------------------------------------------
-
作者:
2018/8/7 13:58:54
6楼:
其他人的格式 xxx?参数1=xx&参数2=xx&参数3=xx datasnap的格式 /xxxx 多个参数,自己拼装解析就好。 关键凭啥,别人都用?带参数,你要用/带
----------------------------------------------
-
作者:
2022/6/25 9:30:09
7楼:
使用以下方式可以获取:xxx?参数1=xx&参数2=xx&参数3=xx 这种标准样式的参数值 var p1: string; p2: string; begin p1 := GetInvocationMetadata.QueryParams.Values['p1']; p2 := GetInvocationMetadata.QueryParams.Values['p2']; Result := Format('Test called,Value:%s,p1:%s,p2:%s',[Value,p1,p2]); end;
----------------------------------------------
delphi|vue|golang hnysoft|hnyerp+mes+srm