Go模板页面浏览器显示HTML源码问题

<!--
 * @Title: This is a  file for ……
 * @Author: JackieZheng
 * @Date: 2024-06-09 17:00:01
 * @LastEditTime: 2024-06-09 17:01:12
 * @LastEditors: Please set LastEditors
 * @Description:
 * @FilePath: \\GoCode\\templates\\index.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

以注释开始的页面会直接在浏览器输出HTML源码

其它情况则都显示正常:

1、无文件头注释 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

2、无 “DOCTYPE”

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

 3、文件头注释下移放其它位置

<!DOCTYPE html>
<!--
 * @Title: This is a  file for ……
 * @Author: JackieZheng
 * @Date: 2024-06-09 17:00:01
 * @LastEditTime: 2024-06-09 17:01:12
 * @LastEditors: Please set LastEditors
 * @Description:
 * @FilePath: \\GoCode\\templates\\index.html
-->
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>Hello {{.name}}</div>
  <div>{{.someStr}}</div>
</body>
</html>

 

 

相关推荐

  1. jsp页面显示问题

    2024-06-10 10:02:03       16 阅读
  2. html】简单网页模板

    2024-06-10 10:02:03       4 阅读

最近更新

  1. PostgreSQL - sql_compatibility 兼容合并库问题

    2024-06-10 10:02:03       0 阅读
  2. NDS域名解析服务

    2024-06-10 10:02:03       0 阅读
  3. 国际化项目开发中关于时间的问题二

    2024-06-10 10:02:03       0 阅读
  4. Linux知识汇总

    2024-06-10 10:02:03       0 阅读
  5. Flink集群运行模式

    2024-06-10 10:02:03       0 阅读
  6. 617作业

    617作业

    2024-06-10 10:02:03      0 阅读
  7. k8s_DaemonSet和Deployment区别

    2024-06-10 10:02:03       0 阅读

热门阅读

  1. 2024前端面试准备4-Vue相关

    2024-06-10 10:02:03       4 阅读
  2. #10 解决Stable Diffusion常见问题和错误

    2024-06-10 10:02:03       5 阅读
  3. 006 CentOS 7.9 elasticsearch7.10.0安装及配置

    2024-06-10 10:02:03       8 阅读
  4. 1341. 电影评分

    2024-06-10 10:02:03       5 阅读
  5. 如何学好量子计算机技术的两种思路

    2024-06-10 10:02:03       5 阅读