关于 模板 Execute转义

hellsam · 2017-12-03 08:58:09 · 1853 次点击 · 大约8小时之前 开始浏览    置顶
这是一个创建于 2017-12-03 08:58:09 的主题,其中的信息可能已经有所发展或是发生改变。

当我传输到前端的时候  我的&email=test  自动转义成了%26email%3dtest  
求解决方案啊, 不让它转义呢? 

var sss2 string = "&email=test"
//sss2 = strings.Replace(sss2, "%26", "&", -1)
m["at"] = sss2  //这个是MAP
tp1.Execute(w, m)

有疑问加站长微信联系(非本文作者)

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1853 次点击  
加入收藏 微博
11 回复  |  直到 2017-12-04 07:18:33
hellsam
hellsam · #1 · 7年之前

放在html的a标签就自动转移了,其他地方没问题纳闷

hellsam
hellsam · #2 · 7年之前

?????

polaris
polaris · #3 · 7年之前

通过 template.HTML(sss2) 转义

hellsam
hellsam · #4 · 7年之前
@polaris 这个我已经试过了 也不行的
放到  
最终得到的依然是%26email%3dtest
hellsam
hellsam · #5 · 7年之前

@polaris

这个我已经试过了 也不行的 放到 <a href="www.xx.com/user?a=admin{{$.at}}" target="_blank"> 最终得到的依然是%26email%3dtest </a>

hellsam
hellsam · #6 · 7年之前

哎 。。再来求助

polaris
polaris · #7 · 7年之前

我说的方式绝对有用啊,studygolang 的源码就这么用了

hellsam
hellsam · #8 · 7年之前

求助 @polaris 我这样写的 不知道是否这样写的 还是写错了呢。

image.png

image.png

image.png

hellsam
hellsam · #9 · 7年之前

m:=make(map[string]interface{}) 这样定义的

polaris
polaris · #10 · 7年之前

你当做 URL 使用,那就得用 template.URL("&email="+email)

hellsam
hellsam · #11 · 7年之前

嗯解决了

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传