【问题标题】:Issue with layoutTitle tag when upgrading to Grails 2.4.4升级到 Grails 2.4.4 时 layoutTitle 标记出现问题
【发布时间】:2015-02-16 02:42:56
【问题描述】:

将我的应用升级到 2.4.4 后使用 g:layoutTitle 标记时出现以下异常

Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.opensymphony.sitemesh.compatability.Content2HTMLPage@21b3cfb7' with class 'com.opensymphony.sitemesh.compatability.Content2HTMLPage' to class 'com.opensymphony.module.sitemesh.parser.AbstractHTMLPage'

我尝试过将字符串硬编码为默认值,如下所示:

<title><g:layoutTitle default="Test"/></title>

我仍然遇到问题。升级时我错过了什么吗?我不确定这里有什么问题。

我在使用 pageProperty 时也遇到了同样的问题。例如:

<body class="${pageProperty(name: 'body.class')} ${pageProperty(name: 'page.sectionName')}">

这会引发相同的异常,但在使用 Grails 2.3.6 时也可以。

【问题讨论】:

  • 我做了更多调试,发现 RenderTagLib.getPage() 导致了这个问题。 return (AbstractHTMLPage)getRequest().getAttribute(PAGE) 导致了这个问题,因为 getAttribute(PAGE) 导致 Content2HTMLPage 类型的对象,它不是 AnstractHTMLPage 的子类,因此是类转换异常。任何想法如何解决这个问题?

标签: grails sitemesh


【解决方案1】:

从 Grails 2.2.5 升级到 2.4.4 后,我遇到了同样的问题。在 Config.groovy 中更改/添加这一行为我解决了这个问题:

    grails.views.gsp.sitemesh.preprocess = true

希望这对某人有所帮助 - 我在这个问题上被难住了几天。

【讨论】:

    猜你喜欢
    • 2014-12-28
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多