Grails 未记录的方法 ifPageProperty 真的有效吗?

发布于 2024-10-16 11:22:04 字数 745 浏览 8 评论 0原文

我正在使用 content 标记在视图中设置 pageProperty,但是,Grails 1.3.6 ifPageProperty 未检测到我的侧边栏 pageProperty。有什么想法吗?

布局.gsp

<g:ifPageProperty name="page.sidebar">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:ifPageProperty>

视图.gsp

<html>
<head>
<title>My Account Title</title>
</head>
<body>
  <content tag="sidebar">
    <h4>Sidebar</h4>
    <p>Hola. This is a sidebar test!</p>
  </content>
  <h1>Content Heading</h1>
</body>
</html>

PS。如果您想知道我在哪里设置布局,它是在控制器中设置的。

I am setting a pageProperty in my view with a content tag, however, Grails 1.3.6 ifPageProperty is not detecting my sidebar pageProperty. Any thoughts?

layout.gsp

<g:ifPageProperty name="page.sidebar">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:ifPageProperty>

view.gsp

<html>
<head>
<title>My Account Title</title>
</head>
<body>
  <content tag="sidebar">
    <h4>Sidebar</h4>
    <p>Hola. This is a sidebar test!</p>
  </content>
  <h1>Content Heading</h1>
</body>
</html>

PS. If you're wondering where I am setting my layout, it's being set in the controller.

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

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

发布评论

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

评论(2

饮惑 2024-10-23 11:22:04

一位同事搜索了 Grails 错误列表,发现必须关闭 Sitemesh 的预处理。

// enable Sitemesh preprocessing of GSP pages
grails.views.gsp.sitemesh.preprocess = false

A coworker scoured the Grails buglist and found out that Sitemesh's preprocess must be turned off.

// enable Sitemesh preprocessing of GSP pages
grails.views.gsp.sitemesh.preprocess = false
痴骨ら 2024-10-23 11:22:04

您可以尝试以下方法来解决该问题:

<g:if test="${g.pageProperty(name:'page.sidebar')?.length()}">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:if>

Could you try this as a workaround for the problem:

<g:if test="${g.pageProperty(name:'page.sidebar')?.length()}">
  <aside id="sidebar">
    <g:pageProperty name="page.sidebar" />
  </aside>
</g:if>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文