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

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

问题描述

在 GWT 应用程序中外部化大量 HTML 的最佳方法是什么?我们有一个相当复杂的 GWT 应用程序,大约有 30 个页面";每个页面的底部都有一种指南,它是几段 HTML 标记.我想将 HTML 外部化,使其尽可能保持未转义".

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.

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

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.)

通常这是您会在 JSP 中放入的那种东西,但我在 GWT 中没有看到任何等效的东西.我正在考虑编写一个小部件,它可以简单地从服务器上的 html 文件中获取内容,然后将文本添加到 HTML 小部件中.但似乎应该有更简单的方法.

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.

推荐答案

您可以使用一些模板机制.尝试 FreeMarkerVelocity 模板.您将在模板库检索的文件中使用 HTML.这些文件可以用适当的扩展名命名,例如.html、.css、.js 可自行观察.

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天全站免登陆