golang url解析问题
本文介绍了golang url解析问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
用golang开启httpserver,如果参数里面有(;)这个符号的话会作为字段值结束,然后分拆出来多一个参数。这个是怎么解决?
即如果我传的是params=111;222
然后golang就解析成两个参数[params=111,222=]
解决方案
;
是HTTP URL中的特殊字符RFC
解决方案
更换分隔符号
使用
URL Encoder
将参数编码,在JS中可以使用encodeURIComponent
Many URL schemes reserve certain characters for a special meaning:
their appearance in the scheme-specific part of the URL has a
designated semantics. If the character corresponding to an octet is
reserved in a scheme, the octet must be encoded. The characters ";",
"/", "?", ":", "@", "=" and "&" are the characters which may be
reserved for special meaning within a scheme. No other characters may
be reserved within a scheme.
这篇关于golang url解析问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文