Import und Verwendung von groovy-code in GSP

Ich bin versucht, einen groovigen Funktion innerhalb eines Aps. Bitte Hilfe, wie ich bin zu TARA mir die Haare aus hier.

Oben auf meiner Aps-ich habe <%@ page import = company.ConstantsFile %>

In meinem GSP habe ich

<p>
I have been in the heating and cooling business for <%(ConstantsFile.daysBetween())%>
</p>

und meine ConstantsFile.groovy

package company

import static java.util.Calendar.*

class ConstantsFile {

    def daysBetween() {
        def startDate = Calendar.instance
        def m = [:]
        m[YEAR] = 2004
        m[MONTH] = "JUNE"
        m[DATE] = 26
        startDate.set(m)
        def today = Calendar.instance

        render today - startDate
    }
}

Ich habe auch versucht, die änderung, dass ein Mieter legt, system.aus, etc, aber das ist nicht mein Hauptproblem.

Error 500: Internal Server Error
URI
/company/
Class
java.lang.NullPointerException
Message
Cannot invoke method daysBetween() on null object

Also versuche ich

<p>
    I have been in the heating and cooling business for <%(new ConstantsFile.daysBetween())%>
    </p>

aber dann bekomme ich

Class: org.codehaus.groovy.control.MultipleCompilationErrorsException

unable to resolve class ConstantsFile.daysBetween @ line 37, column 1. (new ConstantsFile.daysBetween()) ^ 1 error

Bitte jemand mir helfen, oder mir eine website, die zeigt, was zu tun ist.. ich habe versucht zu googeln und alles spricht über eine g:auswählen oder eine andere Art von tag... ich will nur das Ergebnis der Funktion, wie ich früher in den JSPs.

Schreibe einen Kommentar