在模板中渲染 URL RowQuery 字符串 - 不同的行为
Go rendering URL RowQuery string in a template - different behaviours
我是新来的,我被一些非常琐碎的事情困住了,所以我请求你的帮助,也许有人知道为什么会发生这种行为:
我想在模板中输出 url 对象的查询参数字符串,但显然是因为“?” char 放在变量前面,(整个)输出是 url 编码的。问号在go模板中有特殊含义吗?
而不是param1=value1&value2=param2,输出是param1%3dvalue1%26value2%3dparam2
Example 在 go playground
html/template
包的 Go 文档解释了行为 (https://golang.org/pkg/html/template/):
The security model used by this package assumes that template authors are trusted, while Execute's data parameter is not. More details are provided below.
关于这个的事情是你真的应该三思为什么你不希望 Go 将这种安全行为应用到你的模板。
然后,如果您真的确定不想转义字符串,请使用 template.URL
代替字符串:https://play.golang.org/p/kfv2tH6WDG
我是新来的,我被一些非常琐碎的事情困住了,所以我请求你的帮助,也许有人知道为什么会发生这种行为:
我想在模板中输出 url 对象的查询参数字符串,但显然是因为“?” char 放在变量前面,(整个)输出是 url 编码的。问号在go模板中有特殊含义吗?
而不是param1=value1&value2=param2,输出是param1%3dvalue1%26value2%3dparam2
Example 在 go playground
html/template
包的 Go 文档解释了行为 (https://golang.org/pkg/html/template/):
The security model used by this package assumes that template authors are trusted, while Execute's data parameter is not. More details are provided below.
关于这个的事情是你真的应该三思为什么你不希望 Go 将这种安全行为应用到你的模板。
然后,如果您真的确定不想转义字符串,请使用 template.URL
代替字符串:https://play.golang.org/p/kfv2tH6WDG