【问题标题】:how to access my groovy/ grails values from Javascript如何从 Javascript 访问我的 groovy/grails 值
【发布时间】:2011-11-16 05:40:56
【问题描述】:

我的 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 = {
  }
}

现在在我的javascript中我有这个值

var endDate = month + ' ' + endDate.getFullYear();

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

【问题讨论】:

    标签: javascript grails groovy


    【解决方案1】:

    在渲染 gsp 时将其作为 javascript 变量传递,例如:

    <g:javascript>
      window.month = ${month}
    </g:javascript>
    

    month 是你的 grails/gsp 变量

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多