Grails - 多个域名、相关网站

发布于 2024-09-09 02:27:05 字数 193 浏览 2 评论 0原文

我正在构建一个 Grails 应用程序,该应用程序将具有多个类似的网站(每个网站都有自己的域名),这些网站具有相同的代码,但设计和配置不同。 (想想博主)

在单个应用程序上使用不同视图甚至一些不同逻辑而不需要太多黑客攻击的最佳方法是什么?

我是 Grails 新手,我想到的方法是始终检查域名是什么并提供正确的控制器/视图。有更好的办法吗?

Im building a Grails app that will have multiple similar websites (each it's own domain name) with the same code but different design and configuration. (think of blogger)

What is the best method for using different view and even some different logic on a single app without too much hacking?

I'm new to Grails and the method I have in mind is to check all the time to see what the domain name is and to serve the right controller/view. Is there a better way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2024-09-16 02:27:05

我会尝试使用 MultiTenant 插件。你提到观点和逻辑不同,但我猜最不同的是数据?使用 MultiTenant 干净地分离每个站点的数据,而不会造成太多混乱,如果您将视图和逻辑的配置存储在数据库中,那么每个站点也将获得唯一的数据。

我认为 MultiTenant 正在更新到最新的 Grails 版本,至少我在 Grails 邮件列表中看到了这一点。我认为在那之前您需要使用 1.2 版本。

我正在使用 Hibernate Filter 插件做类似分离数据的事情。我的观点是相同的,但我通过首先查找消息“SITE-A.hello.world”来获取每个站点的文本和消息,如果找不到,则检索默认消息“hello.world”。只是为了让您了解如何自定义视图,尽管您可能需要比您的系统更进一步......

I would have a go with the MultiTenant plugin. You mention that views and logic differ, but I'm guessing what will differ most is the data? Use MultiTenant to cleanly separate the data for each site without too much hazzle, and if you store the configuration of views and logic in the DB you get that unique per site as well.

I think MultiTenant is being updated to the latest Grails release, at least I've seen that mentioned in the Grails mail list. I think you need to use an 1.2 release until then.

I'm doing something similar to separate data using the Hibernate Filter plugin. My views are the same but I have per-site texts and messages by looking up message "SITE-A.hello.world" first and if not found the default message "hello.world" is retrieved. Just to give you an idea how views may be customized, though you probably need to take it further than that for your system...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文