【问题标题】:How to load file and format it with dict?如何加载文件并用dict格式化?
【发布时间】:2014-05-15 09:11:06
【问题描述】:

在 Python 中,我可以将文件作为模板加载并用字典替换其形成标记。

如果这是 HTML/文件

<html>
  <body>%(MyVar)s</body
</html>

我可以在 Python 中做到这一点:

f = file("myfile.html").read()
d = {"MyVar":"Hi"}
page = f % d

Java中有类似的东西吗?

【问题讨论】:

    标签: java templates tomcat


    【解决方案1】:

    我建议您使用模板引擎。例如速度,Freemarker。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      • 2012-07-29
      相关资源
      最近更新 更多