在GWT应用程序中外部化HTML的最佳方式是什么? [英] best way to externalize HTML in GWT apps?

查看:76
本文介绍了在GWT应用程序中外部化HTML的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GWT应用中外部化大量HTML 的最佳方式是什么?我们有一个相当复杂的约30页面的GWT应用程序;每个页面在底部都有一些指导,它是HTML标记的几个段落。我想将HTML外部化,以便它可以保持为未转义。



我知道并理解如何使用属性文件在GWT中;这肯定比在Java类中嵌入内容要好,但对于HTML来说仍然很难看(你需要对所有内容进行反斜杠,以及引号等等)

通常情况下,这是您在JSP中放置的类型,但我没有看到与GWT中的任何对等物。我正在考虑只编写一个小部件,它将简单地从服务器上的html文件中获取内容,然后将文本添加到HTML小部件中。但似乎应该有一个更简单的方法。

解决方案

您可以使用一些模板机制。试试 FreeMarker Velocity 模板。您将在HTML文件中获取模板库。这些文件可以用适当的扩展名命名,例如.html,.css,.js可以自己设置。


What's the best way to externalize large quantities of HTML in a GWT app? We have a rather complicated GWT app of about 30 "pages"; each page has a sort of guide at the bottom that is several paragraphs of HTML markup. I'd like to externalize the HTML so that it can remain as "unescaped" as possible.

I know and understand how to use property files in GWT; that's certainly better than embedding the content in Java classes, but still kind of ugly for HTML (you need to backslashify everything, as well as escape quotes, etc.)

Normally this is the kind of thing you would put in a JSP, but I don't see any equivalent to that in GWT. I'm considering just writing a widget that will simply fetch the content from html files on the server and then add the text to an HTML widget. But it seems there ought to be a simpler way.

解决方案

You can use some templating mechanism. Try FreeMarker or Velocity templates. You'll be having your HTML in files that will be retrieved by templating libraries. These files can be named with proper extensions, e.g. .html, .css, .js obsearvable on their own.

这篇关于在GWT应用程序中外部化HTML的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆