如何从Javascript访问我的groovy/grails值

jun*_*idp 1 javascript grails groovy

我的grails课中有一个数组

class BootStrap {

  def init = { servletContext ->
    def myArray = ["Aug 2011","111.0"]
    new IndexValue (indexDate: new Date (),value: 100).save(flush:true)
    assert IndexValue.count()==1
  }

  def destroy = {
  }
}
Run Code Online (Sandbox Code Playgroud)

现在在我的JavaScript中我有这个价值

var endDate = month + ' ' + endDate.getFullYear();
Run Code Online (Sandbox Code Playgroud)

我只需要检查这endDate是否与上面数组中的日期相同,如果有这个日期,只需发出提醒date is present

Igo*_*nov 5

当你渲染gsp时,将它作为javascript变量传递,如:

<g:javascript>
  window.month = ${month}
</g:javascript>
Run Code Online (Sandbox Code Playgroud)

month你的grails/gsp变量在哪里