Grails 在 div 内显示 gsp
嘿。想象一下我有两个独立的 gsp 页面,具有不同的 css 格式(两个页面之间存在名称冲突)。我想在另一页的 div 内“显示”或渲染一个页面及其 ows 格式。想象一下这种情况:
page1.gsp
...
...
<div id="here"></div>
...
...
page2.gsp
Hello there!
我希望我的最终页面是:
...
...
Hello there!
...
...
可以这样做吗?
Hey. Imagine i have two separate gsp pages with diferent css formatting (with name conflicts between two). And i want to "display" or render one page with its ows formatation inside a div in the other page. Imagining this scenario:
page1.gsp
...
...
<div id="here"></div>
...
...
page2.gsp
Hello there!
I want my final page to be:
...
...
Hello there!
...
...
Is it possible to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,使用 g:render 标签并创建一个“片段”页面来包含您的内容。
然后使用 g:render 标签将其拉入。
有关此内容的更多详细信息,请参阅文档或教程。
Yes use the g:render tag and create a "fragment" page to contain your content.
then use the g:render tag to pull it in.
Refer to the documentation or tutorials for more detail on this.
这和我前几天发的一个问题很相似:
我可以使用独立样式表显示内部潜水吗?< /a>
This is very similar to a question I posted a couple of days ago:
Can I display an inner dive with an independent stylesheet?
您想在每个页面上执行此操作吗? (像布局一样?)
如果是这种情况,请使用 SiteMesh(已内置)
{app}/grails-app/views/layouts/mylayout.gsp
{app}/grails-app/views/{somefolder}/page1。 gsp
如果您已经有了它,并且只是想分解页面并保持它们干燥..
{app}/grails-app/views/{somefolder}/page1.gsp
* Model 属性渲染是可选的,但适用于将数据传递到要渲染的模板
{app}/grails-app/views/{somefolder}/_page2.gsp
* 注意 gsp 名称之前的“_” 。 (模板页面约定)
查看 渲染和模板
Is this something you want to work for every page? (Like a layout?)
If that is the case, use SiteMesh (built in already)
{app}/grails-app/views/layouts/mylayout.gsp
{app}/grails-app/views/{somefolder}/page1.gsp
If you already have that, and are just looking at breaking up you pages and keeping them DRY..
{app}/grails-app/views/{somefolder}/page1.gsp
* The Model property of render is optional, but works for passing data to the template to be rendered
{app}/grails-app/views/{somefolder}/_page2.gsp
* Notice the "_" before the gsp name. (Convention for Template pages)
Checkout the documentation for render and templating