我创建一个Grails web应用程序,并有主索引GSP,有这将是通用的大部分,我使用的部分模板网站上的网页的几种常见的组成部分。
I am creating a grails webapp, and have the main index gsp, and there are several common components that will be common across most of the pages on the site that I am using partial templates for.
每个局部模板将是相当孤立,并包含非常不同的信息,所以每个人应该得到从不同的控制器信息。
Each partial template will be quite isolated and contain very different information, so each one should be getting info from different controllers.
我要的是在页面加载,每个局部模板拨打电话到控制器加载所需的内容 - 林希望能有一些标签,我可以很容易地在我的部分模板放在指定的控制器/行动将自动呼吁负载控制器。
What I want is on page loading, for each partial template to make a call to a controller to load the required content - Im hoping there is some tag I can easily place in my partial templates specifying a controller/action that will automatically call the controllers on load.
这可能吗?
----编辑-----
此外,部分模板控制器中的一个将被回拉从一个Web服务,可能需要一些时间的信息,所以这将是很好的,如果我还可以异步加载这些模板。
Also, one of the partial templates' controllers will be pulling back information from a web service that can take some time, so it would be good if i could also load these templates asynchronously..
谢谢!
这是什么的< G:包括> 标记为。如果加上 springcache插件和使用页面片段缓存。 由于包括呼叫控制器中的一个常规动作,你也可以通过Ajax调用使用它。
That's what the <g:include> Tag is for. It's very useful by itself but even more if combined with the springcache plugin and using page fragment caching. Since the include calls a regular action in a controller you can also consume it by an ajax call.